Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3385588
D12524.id41806.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12524.id41806.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 1:08 AM (20 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2598898
Default Alt Text
D12524.id41806.diff (3 KB)
Attached To
Mode
D12524: [lib] implement sending message to Tunnelbroker
Attached
Detach File
Event Timeline
Log In to Comment