private void _hwsClient_DataReceived(object sender, DataReceivedEventArgs e) { var strMsg = Encoding.UTF8.GetString(GZip.Decompress(e.Data)); if (strMsg.Contains("state.update") || strMsg.Contains("state.updateall") || strMsg.Contains("pong")) { return; } if (strMsg.Contains("status") && strMsg.Contains("success")) { var updateModel = JSONHelper.ConvertToObject <HotbitUpdateModel>(strMsg); if (updateModel.id == SUB_REQ_ID) { OnConnectionOpened?.Invoke(this, this.SubItemName); } else if (updateModel.id == SUB_AUTH_ID) { var authModel = this.SubModel as AuthSubscribeModel; authModel.reqList.ForEach(p => _hwsClient.Send(p.ToJson())); } return; } //_logger.Info($"recieve@{strMsg}@{Title}"); if (this.SubscribeType == "ASSET" && strMsg.Contains("result")) { strMsg = strMsg.Replace("error", "method").Replace("null", "\"asset.update\"").Replace("result", "params"); strMsg = strMsg.Replace("\"params\":", "\"params\":[").Replace("}}", "}}]"); strMsg = strMsg.Replace("}, ", "}},{"); } OnRecieveMessage?.Invoke(this, strMsg); }
// call when client connect to server successful static void ConnectionOpened(Connection connection) { Unity.Console.DebugLog("Connected to", connection.FullUrl); if (!OnConnectionOpened.IsNull()) { OnConnectionOpened(connection); } }
void ConnectionOpened(Response response) { Unity.Console.DebugLog("ApiManager class", Unity.Console.SetMagentaColor("Regular Callback:"), "ConnectionOpened()"); InitializeApi(LoginApi.Create(this)); response.SendResultData <string>(url => { if (OnConnectionOpened != null) { OnConnectionOpened.Invoke(url); } }); }
public void OpenConnection(string ip) { socket = IO.Socket(String.IsNullOrEmpty(ip) ? CONNECTION_URL + ":" + CONNECTION_PORT : "http://" + ip); socket.On(Socket.EVENT_CONNECT, () => { socket.Emit("connection", "AudioLightClient"); OnConnectionOpened.Invoke(this, new EventArgs()); }); socket.On(Socket.EVENT_CONNECT_ERROR, () => { OnFailedConnection.Invoke(this, new EventArgs()); }); }
public void OpenConnection(string port) { try { serialPort.PortName = String.IsNullOrEmpty(port) ? PORT_NAME : port; serialPort.Open(); OnConnectionOpened?.Invoke(this, new EventArgs()); } catch (Exception e) { Console.WriteLine(e.Message); OnFailedConnection?.Invoke(this, new EventArgs()); } }
private void OpenConnection() { if (connection == null) { connection = CreateConnection(); } if (connection.State != ConnectionState.Open) { connection.ConnectionString = ConnectionString; connection.Open(); if (!Schema.IsEmpty()) { SetSchema(connection, Schema); } OnConnectionOpened?.Invoke(this); } }
private void ConnectionOpened(Response response) { CustomTools.Console.DebugLog("EchoApiManager class", CustomTools.Console.LogMagentaColor("Regular Callback:"), "ConnectionOpened()"); InitializeApi(LoginApi.Create(this)); response.SendResultData <string>(url => OnConnectionOpened.SafeInvoke(url), null); }
protected override void OnOpen() { OnConnectionOpened?.Invoke(this); }
// call when client connect to server successful private static void ConnectionOpened(Connection connection) { CustomTools.Console.DebugLog("Connected to", connection.FullUrl); OnConnectionOpened.SafeInvoke(connection); }