private void OnSocketError(string message, SocketError se) { NetWorkEvent bitSwarmEvent = new NetWorkEvent(NetWorkEvent.IO_ERROR); bitSwarmEvent.Params = new Dictionary <string, object>(); bitSwarmEvent.Params["message"] = message + " ==> " + se; DispatchEvent(bitSwarmEvent); }
private void OnSocketConnect() { attemptingReconnection = false; NetWorkEvent networkEvent = new NetWorkEvent(NetWorkEvent.CONNECT); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["success"] = true; dictionary["isReconnection"] = attemptingReconnection; networkEvent.Params = dictionary; DispatchEvent(networkEvent); }
private void OnSocketData(ByteBuffer data) { try { ioHandler.OnDataRead(data); } catch (Exception ex) { NetWorkEvent bitSwarmEvent = new NetWorkEvent(NetWorkEvent.DATA_ERROR); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["message"] = ex.ToString(); bitSwarmEvent.Params = dictionary; DispatchEvent(bitSwarmEvent); } }
private void OnSocketConnectFailure() { if (!attemptingReconnection) { firstReconnAttempt = DateTime.Now; } attemptingReconnection = true; NetWorkEvent networkEvent = new NetWorkEvent(NetWorkEvent.CONNECTFAILURE); Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["success"] = false; dictionary["isReconnection"] = attemptingReconnection; networkEvent.Params = dictionary; DispatchEvent(networkEvent); Reconnect(); }
private void DispatchEvent(NetWorkEvent evt) { dispatcher.DispatchEvent(evt); }