Skip to content

Commit

Permalink
feat: update log info & fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
wqcstrong committed Jun 16, 2023
1 parent 40cfc0c commit a5490df
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/utils/message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function makeUnicastMessage(

export function makeBroadcastMessage(
msg: SpyMessage.MessageItem,
): SpySocket.BrodcastEvent {
): SpySocket.BroadcastEvent {
return {
type: SERVER_MESSAGE_TYPE.BROADCAST,
content: {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class SocketStore {
private timer: number | null = null;

// messages store
private messages: (SpySocket.BrodcastEvent | SpySocket.UnicastEvent)[] = [];
private messages: (SpySocket.BroadcastEvent | SpySocket.UnicastEvent)[] = [];

// events center
private events: Record<SpyMessage.InteractiveType, SocketEventCallback[]> = {
Expand Down Expand Up @@ -78,7 +78,7 @@ export class SocketStore {
public init(url: string) {
try {
if (!url) {
throw Error('[PageSpy] WebSocket url cannot be empty');
throw Error('WebSocket url cannot be empty');
}
this.socket = new WebSocket(url);
this.socketUrl = url;
Expand All @@ -95,7 +95,7 @@ export class SocketStore {
this.connectOffline();
});
} catch (e: any) {
alert(`[PageSpy] ${e.message}`);
psLog.error(e.message);
}
}

Expand Down Expand Up @@ -244,7 +244,7 @@ export class SocketStore {
/* c8 ignore start */
this.messages
.slice(msgIndex + 1)
.forEach((msg: SpySocket.BrodcastEvent | SpySocket.UnicastEvent) => {
.forEach((msg: SpySocket.BroadcastEvent | SpySocket.UnicastEvent) => {
const data = {
type: SERVER_MESSAGE_TYPE.MESSAGE,
content: {
Expand Down
6 changes: 3 additions & 3 deletions types/lib/socket-event.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type CloseEvent = EventConstructor<
reason: string;
}
>;
export type BrodcastEvent = EventConstructor<
export type BroadcastEvent = EventConstructor<
'broadcast',
{
data: MessageItem;
Expand All @@ -69,13 +69,13 @@ export type ErrorEvent = EventConstructor<
}
>;
export type PingEvent = EventConstructor<'ping', any>;
export type ClientEvent = UnicastEvent | BrodcastEvent | PingEvent;
export type ClientEvent = UnicastEvent | BroadcastEvent | PingEvent;
export type Event =
| JoinEvent
| ConnectEvent
| LeaveEvent
| CloseEvent
| BrodcastEvent
| BroadcastEvent
| UnicastEvent
| ErrorEvent
| PingEvent;

0 comments on commit a5490df

Please sign in to comment.