Skip to content

Commit

Permalink
export SocketReadyState as a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisjiang committed Aug 15, 2024
1 parent 1139d70 commit 8fb5aed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/std/socket/mina_socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function connectSocket(url: string, options?: SocketOptions): ISocket {
});

// mock WebSocket readyState
let readyState = SocketReadyState.CONNECTING;
let readyState: number = SocketReadyState.CONNECTING;

return {
get readyState(): number {
Expand Down
12 changes: 6 additions & 6 deletions src/std/socket/socket_define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import type { AsyncVoidIOResult } from 'happy-rusty';
/**
* WebSocket 连接状态,小游戏环境可用。
*/
export const enum SocketReadyState {
export const SocketReadyState = {
/**
* WebSocket.CONNECTING
*/
CONNECTING = 0,
CONNECTING: 0,
/**
* WebSocket.OPEN
*/
OPEN = 1,
OPEN: 1,
/**
* WebSocket.CLOSING
*/
CLOSING = 2,
CLOSING: 2,
/**
* WebSocket.CLOSED
*/
CLOSED = 3,
}
CLOSED: 3,
} as const;

/**
* WebSocket 事件监听器映射接口,定义了与 WebSocket 事件对应的回调函数类型。
Expand Down

0 comments on commit 8fb5aed

Please sign in to comment.