Page MenuHomePhabricator

D12524.diff
No OneTemporary

D12524.diff

diff --git a/lib/tunnelbroker/secondary-tunnelbroker-connection.js b/lib/tunnelbroker/secondary-tunnelbroker-connection.js
--- a/lib/tunnelbroker/secondary-tunnelbroker-connection.js
+++ b/lib/tunnelbroker/secondary-tunnelbroker-connection.js
@@ -1,14 +1,19 @@
// @flow
import type { MessageToDeviceRequest } from '../types/tunnelbroker/message-to-device-request-types.js';
+import type { MessageToTunnelbrokerRequest } from '../types/tunnelbroker/message-to-tunnelbroker-request-types.js';
type RemoveCallback = () => void;
export type SecondaryTunnelbrokerConnection = {
// Used by an inactive tab to send messages
- +sendMessage: MessageToDeviceRequest => mixed,
+ +sendMessage: (
+ MessageToDeviceRequest | MessageToTunnelbrokerRequest,
+ ) => mixed,
// Active tab receives messages from inactive tabs
- +onSendMessage: ((MessageToDeviceRequest) => mixed) => RemoveCallback,
+ +onSendMessage: (
+ (MessageToDeviceRequest | MessageToTunnelbrokerRequest) => mixed,
+ ) => RemoveCallback,
// Active tab sets the message status of messages from inactive tabs
+setMessageStatus: (messageID: string, error: ?string) => mixed,
diff --git a/lib/tunnelbroker/tunnelbroker-context.js b/lib/tunnelbroker/tunnelbroker-context.js
--- a/lib/tunnelbroker/tunnelbroker-context.js
+++ b/lib/tunnelbroker/tunnelbroker-context.js
@@ -14,6 +14,7 @@
import { isWebPlatform } from '../types/device-types.js';
import type { MessageSentStatus } from '../types/tunnelbroker/message-to-device-request-status-types.js';
import type { MessageToDeviceRequest } from '../types/tunnelbroker/message-to-device-request-types.js';
+import type { MessageToTunnelbrokerRequest } from '../types/tunnelbroker/message-to-tunnelbroker-request-types.js';
import {
type TunnelbrokerMessage,
tunnelbrokerMessageTypes,
@@ -59,6 +60,7 @@
message: TunnelbrokerClientMessageToDevice,
messageID: ?string,
) => Promise<void>,
+ +sendMessageToTunnelbroker: (payload: string) => Promise<void>,
+addListener: (listener: TunnelbrokerSocketListener) => void,
+removeListener: (listener: TunnelbrokerSocketListener) => void,
+socketState: TunnelbrokerSocketState,
@@ -309,7 +311,7 @@
]);
const sendMessageToDeviceRequest: (
- request: MessageToDeviceRequest,
+ request: MessageToDeviceRequest | MessageToTunnelbrokerRequest,
) => Promise<void> = React.useCallback(
request => {
return new Promise((resolve, reject) => {
@@ -349,6 +351,20 @@
[sendMessageToDeviceRequest],
);
+ const sendMessageToTunnelbroker: (payload: string) => Promise<void> =
+ React.useCallback(
+ (payload: string) => {
+ const clientMessageID = uuid.v4();
+ const messageToTunnelbroker: MessageToTunnelbrokerRequest = {
+ type: tunnelbrokerMessageTypes.MESSAGE_TO_TUNNELBROKER_REQUEST,
+ clientMessageID,
+ payload,
+ };
+ return sendMessageToDeviceRequest(messageToTunnelbroker);
+ },
+ [sendMessageToDeviceRequest],
+ );
+
React.useEffect(
() =>
secondaryTunnelbrokerConnection?.onSendMessage(message => {
@@ -419,12 +435,19 @@
const value: TunnelbrokerContextType = React.useMemo(
() => ({
sendMessage,
+ sendMessageToTunnelbroker,
socketState,
addListener,
removeListener,
setUnauthorizedDeviceID,
}),
- [sendMessage, socketState, addListener, removeListener],
+ [
+ sendMessage,
+ sendMessageToTunnelbroker,
+ socketState,
+ addListener,
+ removeListener,
+ ],
);
return (

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 10:48 AM (21 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584313
Default Alt Text
D12524.diff (3 KB)

Event Timeline