-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eb8acb
commit 2a37862
Showing
12 changed files
with
483 additions
and
359 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 47 additions & 32 deletions
79
packages/3d-web-text-chat/src/chat-network/ChatNetworkingMessages.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,73 @@ | ||
export const IDENTITY_MESSAGE_TYPE = "identity"; | ||
export const USER_AUTHENTICATE_MESSAGE_TYPE = "user_auth"; | ||
export const CONNECTED_MESSAGE_TYPE = "connected"; | ||
export const DISCONNECTED_MESSAGE_TYPE = "disconnected"; | ||
export const PING_MESSAGE_TYPE = "ping"; | ||
export const PONG_MESSAGE_TYPE = "pong"; | ||
export const CHAT_MESSAGE_TYPE = "chat"; | ||
|
||
export type IdentityMessage = { | ||
type: typeof IDENTITY_MESSAGE_TYPE; | ||
export const CHAT_NETWORKING_IDENTITY_MESSAGE_TYPE = "identity"; | ||
export const CHAT_NETWORKING_USER_AUTHENTICATE_MESSAGE_TYPE = "user_auth"; | ||
export const CHAT_NETWORKING_CONNECTED_MESSAGE_TYPE = "connected"; | ||
export const CHAT_NETWORKING_DISCONNECTED_MESSAGE_TYPE = "disconnected"; | ||
export const CHAT_NETWORKING_SERVER_ERROR_MESSAGE_TYPE = "error"; | ||
export const CHAT_NETWORKING_PING_MESSAGE_TYPE = "ping"; | ||
export const CHAT_NETWORKING_PONG_MESSAGE_TYPE = "pong"; | ||
export const CHAT_NETWORKING_CHAT_MESSAGE_TYPE = "chat"; | ||
|
||
export type ChatNetworkingIdentityMessage = { | ||
type: typeof CHAT_NETWORKING_IDENTITY_MESSAGE_TYPE; | ||
id: number; | ||
}; | ||
|
||
export type ConnectedMessage = { | ||
type: typeof CONNECTED_MESSAGE_TYPE; | ||
export type ChatNetworkingConnectedMessage = { | ||
type: typeof CHAT_NETWORKING_CONNECTED_MESSAGE_TYPE; | ||
id: number; | ||
}; | ||
|
||
export type DisconnectedMessage = { | ||
type: typeof DISCONNECTED_MESSAGE_TYPE; | ||
export type ChatNetworkingDisconnectedMessage = { | ||
type: typeof CHAT_NETWORKING_DISCONNECTED_MESSAGE_TYPE; | ||
id: number; | ||
}; | ||
|
||
export type FromServerPingMessage = { | ||
type: typeof PING_MESSAGE_TYPE; | ||
export const CHAT_NETWORKING_SERVER_SHUTDOWN_ERROR_TYPE = "SERVER_SHUTDOWN"; | ||
export const CHAT_NETWORKING_UNKNOWN_ERROR = "UNKNOWN_ERROR"; | ||
|
||
export type ChatNetworkingServerErrorType = | ||
| typeof CHAT_NETWORKING_SERVER_SHUTDOWN_ERROR_TYPE | ||
| typeof CHAT_NETWORKING_UNKNOWN_ERROR; | ||
|
||
export type ChatNetworkingServerError = { | ||
type: typeof CHAT_NETWORKING_SERVER_ERROR_MESSAGE_TYPE; | ||
errorType: ChatNetworkingServerErrorType; | ||
message: string; | ||
}; | ||
|
||
export type ChatNetworkingServerPingMessage = { | ||
type: typeof CHAT_NETWORKING_PING_MESSAGE_TYPE; | ||
}; | ||
|
||
export type FromServerChatMessage = { | ||
type: typeof CHAT_MESSAGE_TYPE; | ||
export type ChatNetworkingServerChatMessage = { | ||
type: typeof CHAT_NETWORKING_CHAT_MESSAGE_TYPE; | ||
id: number; | ||
text: string; | ||
}; | ||
|
||
export type FromServerMessage = | ||
| IdentityMessage | ||
| ConnectedMessage | ||
| DisconnectedMessage | ||
| FromServerPingMessage | ||
| FromServerChatMessage; | ||
| ChatNetworkingIdentityMessage | ||
| ChatNetworkingConnectedMessage | ||
| ChatNetworkingDisconnectedMessage | ||
| ChatNetworkingServerPingMessage | ||
| ChatNetworkingServerChatMessage | ||
| ChatNetworkingServerError; | ||
|
||
export type FromClientPongMessage = { | ||
type: typeof PONG_MESSAGE_TYPE; | ||
export type ChatNetworkingClientPongMessage = { | ||
type: typeof CHAT_NETWORKING_PONG_MESSAGE_TYPE; | ||
}; | ||
|
||
export type FromClientAuthenticateMessage = { | ||
type: typeof USER_AUTHENTICATE_MESSAGE_TYPE; | ||
export type ChatNetworkingClientAuthenticateMessage = { | ||
type: typeof CHAT_NETWORKING_USER_AUTHENTICATE_MESSAGE_TYPE; | ||
sessionToken: string; | ||
}; | ||
|
||
export type FromClientChatMessage = { | ||
type: typeof CHAT_MESSAGE_TYPE; | ||
export type ChatNetworkingClientChatMessage = { | ||
type: typeof CHAT_NETWORKING_CHAT_MESSAGE_TYPE; | ||
text: string; | ||
}; | ||
|
||
export type FromClientMessage = | ||
| FromClientPongMessage | ||
| FromClientAuthenticateMessage | ||
| FromClientChatMessage; | ||
| ChatNetworkingClientPongMessage | ||
| ChatNetworkingClientAuthenticateMessage | ||
| ChatNetworkingClientChatMessage; |
Oops, something went wrong.