using System; namespace UnityWebSocket { /// /// IWebSocket indicate a network connection. /// It can be connecting, connected, closing or closed state. /// You can send and receive messages by using it. /// Register callbacks for handling messages. /// ----------------------------------------------------------- /// IWebSocket 表示一个网络连接, /// 它可以是 connecting connected closing closed 状态, /// 可以发送和接收消息, /// 通过注册消息回调,来处理接收到的消息。 /// public interface IWebSocket { /// /// Establishes a connection asynchronously. /// /// /// /// This method does not wait for the connect process to be complete. /// /// /// This method does nothing if the connection has already been /// established. /// /// /// /// /// This instance is not a client. /// /// /// -or- /// /// /// The close process is in progress. /// /// /// -or- /// /// /// A series of reconnecting has failed. /// /// void ConnectAsync(); /// /// Closes the connection asynchronously. /// /// /// /// This method does not wait for the close to be complete. /// /// /// This method does nothing if the current state of the connection is /// Closing or Closed. /// /// void CloseAsync(); /// /// Sends the specified data asynchronously using the WebSocket connection. /// /// /// This method does not wait for the send to be complete. /// /// /// An array of that represents the binary data to send. /// /// /// The current state of the connection is not Open. /// /// /// is . /// void SendAsync(byte[] data); /// /// Sends the specified data using the WebSocket connection. /// /// /// A that represents the text data to send. /// /// /// The current state of the connection is not Open. /// /// /// is . /// /// /// could not be UTF-8 encoded. /// void SendAsync(string text); /// /// get the address which to connect. /// string Address { get; } /// /// get sub protocols . /// string[] SubProtocols { get; } /// /// Gets the current state of the connection. /// /// /// /// One of the enum values. /// /// /// It indicates the current state of the connection. /// /// /// The default value is . /// /// WebSocketState ReadyState { get; } /// /// Gets the current binaryType of the connection, supported on WEBGL platform only. /// /// /// /// It indicates the current binaryType of the connection. /// /// /// The default value is "arraybuffer", options: "blob" or "arraybuffer". /// /// string BinaryType { get; set; } /// /// Occurs when the WebSocket connection has been established. /// event EventHandler OnOpen; /// /// Occurs when the WebSocket connection has been closed. /// event EventHandler OnClose; /// /// Occurs when the gets an error. /// event EventHandler OnError; /// /// Occurs when the receives a message. /// event EventHandler OnMessage; } }