public override void Setup(string ip, int port) { base.Setup(ip, port); _socket = new WebSocketSharp.WebSocket(NetTool.GetAddress(ip, port) + "/default"); _socket.Log.Level = WebSocketSharp.LogLevel.Error; // _socket.WaitTime = TimeSpan.FromSeconds(1); _socket.OnOpen += (a, b) => { base.OnConnected(); }; _socket.OnClose += (a, b) => { base.OnClosed(); }; _socket.OnMessage += (a, b) => { base.OnReceived(b.RawData); }; }
public override void Setup(string ip, int port) { base.Setup(ip, port); _server = new WebSocketSharp.Server.WebSocketServer(NetTool.GetAddress(ip, port)); _server.Log.Level = WebSocketSharp.LogLevel.Error; // _server.WaitTime = TimeSpan.FromSeconds(1); _server.AddWebSocketService(defaultServicePath, () => { WebSocketSession session = new WebSocketSession(SendAction); session.onConnected = () => { OnSessionConnected(session); }; session.onClosed = () => { OnSessionClosed(session); }; session.onReceived = (data) => { OnSessionReceived(session, data); }; return(session.behavior); }); }