/* The Message is the structure which describes the icoming data (and if `Conn.Write` is manually used to write). */
classMessage{
wait:string;
/* The Namespace that this message sent to. */
Namespace:string;
/* The Room that this message sent to. */
Room:string;
/* The Event that this message sent to. */
Event:string;
/* The actual body of the incoming data. */
Body:WSData;
/* The Err contains any message's error if defined and not empty.
server-side and client-side can return an error instead of a message from inside event callbacks. */
Err:Error;
isError:boolean;
isNoOp:boolean;
isInvalid:boolean;
/* The IsForced if true then it means that this is not an incoming action but a force action.
For example when websocket connection lost from remote the OnNamespaceDisconnect `Message.IsForced` will be true */
IsForced:boolean;
/* The IsLocal reprots whether an event is sent by the client-side itself, i.e when `connect` call on `OnNamespaceConnect` event the `Message.IsLocal` will be true,
server-side can force-connect a client to connect to a namespace as well in this case the `IsLocal` will be false. */
IsLocal:boolean;
/* The IsNative reports whether the Message is websocket native messages, only Body is filled. */
IsNative:boolean;
/* The SetBinary can be filled to true if the client must send this message using the Binary format message.
// throw new Error("this browser does not support Text Encoding/Decoding...");
// }
// (msg.Body as unknown) = new TextEncoder().encode(msg.Body);
// }
// this.conn.send(serializeMessage(msg));
//
// var data:string|Uint8Array = serializeMessage(msg)
// if (msg.SetBinary) {
// if (!("TextEncoder" in window)) {
// throw new Error("this browser does not support Text Encoding/Decoding...");
// }
// data = new TextEncoder().encode(data);
// }
// this.conn.send(data);
this.conn.send(serializeMessage(msg));
returntrue;
}
writeEmptyReply(wait:string):void{
this.conn.send(genEmptyReplyToWait(wait));
}
/* The close method will force-disconnect from all connected namespaces and force-leave from all joined rooms
and finally will terminate the underline websocket connection. After this method call the `Conn` is not usable anymore, a new `dial` call is required. */