Skip to content

Splitted to single files and support sending string type message. #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions Plugins/IWebSocket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
namespace HybridWebSocket
/*
* unity-websocket-webgl
*
* @author Jiri Hybek <[email protected]>
* @copyright 2018 Jiri Hybek <[email protected]>
* @license Apache 2.0 - See LICENSE file distributed with this source code.
*/

/*
* @edited by Khiem (Kei) Nguyen.
* Splitted to single files and support sending string type message.
*/

{
/// <summary>
/// WebSocket class interface shared by both native and JSLIB implementation.
/// </summary>
public interface IWebSocket
{
bool IsAlive { get; }

/// <summary>
/// Open WebSocket connection
/// </summary>
void Connect ();

/// <summary>
/// Close WebSocket connection with optional status code and reason.
/// </summary>
/// <param name="code">Close status code.</param>
/// <param name="reason">Reason string.</param>
void Close (WebSocketCloseCode code = WebSocketCloseCode.Normal, string reason = null);

/// <summary>
/// Send binary data over the socket.
/// </summary>
/// <param name="data">Payload data.</param>
void Send (byte[] data);

/// <summary>
/// Send binary data over the socket.
/// </summary>
/// <param name="str">Payload data.</param>
void Send (string str);

/// <summary>
/// Return WebSocket connection state.
/// </summary>
/// <returns>The state.</returns>
WebSocketState GetState ();

/// <summary>
/// Occurs when the connection is opened.
/// </summary>
event WebSocketOpenEventHandler OnOpen;

/// <summary>
/// Occurs when a message is received.
/// </summary>
event WebSocketMessageEventHandler OnMessage;

/// <summary>
/// Occurs when an error was reported from WebSocket.
/// </summary>
event WebSocketErrorEventHandler OnError;

/// <summary>
/// Occurs when the socked was closed.
/// </summary>
event WebSocketCloseEventHandler OnClose;
}
}
Loading