private void Init_WebSocket(ConfigKeyBoard conf) { string ws = "ws://"; if (conf.IsHttps) { ws = "wss://"; } string url = ws + conf.HttpCetm + "/room/actor/join?branch_code=" + conf.StoreCode + "&actor_type=superbox&user_id=" + "&reconnect_count=0&is_uid=1";; //string url = ws + conf.IsHttps + "/room/actor/join?branch_code=" + conf.StoreCode + "&actor_type=counter&counter_code=" + conf.counter_code + "&user_id=" + conf.user.id + "&reconnect_count=0"; webSocket = new WebSocket(url); webSocket.Opened += websocket_Opened; webSocket.Error += websocket_Error; webSocket.Closed += websocket_Closed; webSocket.MessageReceived += websocket_MessageReceived; webSocket.EnableAutoSendPing = true; try { webSocket.Open(); } catch { OpendSocket(); } }
public static ConfigKeyBoard GetConfigByFileConfig() { try { Serializer ser = new Serializer(); string path = string.Empty; string xmlInputData = string.Empty; string xmlOutputData = string.Empty; path = Directory.GetCurrentDirectory() + @"\ConfigKeyBoard.xml"; xmlInputData = File.ReadAllText(path); ConfigKeyBoard customer2 = ser.Deserialize <ConfigKeyBoard>(xmlInputData); xmlOutputData = ser.Serialize <ConfigKeyBoard>(customer2); if (customer2.IsHttps) { customer2.https = "https://" + customer2.HttpCetm; } else { customer2.https = "http://" + customer2.HttpCetm; } return(customer2); } catch (Exception ex) { throw new Exception(ex.Message); } }
static void GetInitSetCache() { config = MRW_Common.GetConfigByFileConfig(); if (config != null) { hideConsole(config.Hide); } comName = GetCom(config.Com.Trim()); }
public void InitSocketLib(ConfigKeyBoard conf, Priority pri) { config = conf; this.resPri = pri; initParam(); //Init_WebSocket(conf); SetTimerPing(); //InitBackground(); SetThreadExecutionState(ActionTicket.ES_CONTINUOUS | ActionTicket.ES_SYSTEM_REQUIRED | ActionTicket.ES_AWAYMODE_REQUIRED); Init_WebSocket(conf); }
private static void InitSocket(ConfigKeyBoard config, Priority pri) { //socket = new SocketLib(config, pri); socket.InitSocketLib(config, pri); socket.DataReceived += ReciveDataSocket; }