public UMBackgroundWorker(ProgressChanged <O> pc, ReceiveMsgDelegate rcvMsg, SendMsgDelegate sm = null, ProcessMsgDelegateRXRaw pm = null) { this.pc = pc; this.rcvMsg = rcvMsg; this.sm = sm; this.pm = pm; }
public ConnectivityModel(string umdurl, ushort umdport, string name, string winurl, ushort winport, ReceiveMsgDelegate rmCB, SendMsgDelegate smCB) { this.umdurl = umdurl; this.umdport = umdport; this.name = name; this.winurl = winurl; this.winport = winport; if (rmCB != null) { rm = rmCB; } else { rm = new ReceiveMsgDelegate(MsgProcessor.ReceiveMessage); } if (smCB != null) { sm = smCB; } else { sm = new SendMsgDelegate(MsgProcessor.SendMessage); } InitConnections(); }
public ClientToServerConnection(SocketSettings socSet, ref SendMsgDelegate sm, ReceiveMsgDelegate rm) { Logger.Info($"{name} Client Connectng to server Connection: ws://{url}:{port}"); this.url = socSet.url; this.port = socSet.port; this.name = socSet.name; this.socSet = socSet; this.rm = rm; sm = new SendMsgDelegate(SendCommandToServer); Logger.AppName = socSet.name; }
public void Init(UMDAppConfig config) { rm = new ReceiveMsgDelegate(ReceiveMessage); pmRx = new ProcessMsgDelegateRXRaw(HandleClientCmd); AppName = config.AppName; Logger.Debug($"{config.AppName} Connection init"); if (config.srvSet == null) { Logger.Error($"{config.AppName} Missing Configuration Server Settings"); throw new Exception($"{config.AppName} Missing Configuration Server Settings."); } // wsrv = new WalletServer(config); }
public void Init(SocketSettings sockSet, ref SendMsgDelegate sm, ReceiveMsgDelegate rm = null) { Url = sockSet.url; Port = sockSet.port; name = sockSet.name; this.sockSet = sockSet; Logger.Info($"Client Socket Connection Init: {name}"); if (rm == null) { rm = new ReceiveMsgDelegate(MsgProcessor.ReceiveMessage); } srvr = new ClientToServerConnection(sockSet, ref sm, rm); smsg = new SendMessages(sm); }
// static UMBackgroundWorker<IMDMMessage>.ProgressChanged<IMDMMessage> main = null; public ConnectionVM(SocketSettings srvSet = null, ReceiveMsgDelegate rmsg = null, SendMsgDelegate smsg = null)// :base(main, "ConnectionVM") { if (srvSet != null) { srv = srvSet; } if (rmsg != null) { rm = rmsg; } if (smsg != null) { sm = smsg; } connectivityModel = new ConnectivityModel(srv.url, srv.port, srv.name, srv.clienturl, srv.clientport, rm, sm); }
public void Init(UMDAppConfig config) { rm = new ReceiveMsgDelegate(ReceiveMessage); pmRx = new ProcessMsgDelegateRXRaw(HandleClientCmd); AppName = config.AppName; Logger.Debug($"{config.AppName} Connection init"); if (config.srvSet == null) { Logger.Error($"{config.AppName} Missing Configuration Server Settings"); throw new Exception($"{config.AppName} Missing Configuration Server Settings."); } conn = new ClientToServerConnection(config.srvSet, ref sm, rm); conn.Connect(); UMDServer = new UMDManifest(config.SQLConn); drillDown = new ManifestDetails(sm, rm, pmRx); }
public void Init(UMDAppConfig config) { rm = new ReceiveMsgDelegate(ReceiveMessage); WinsysTxFiles = new WinSysDBFile(config.winsysFiles.WinsysSrcFile, config.winsysFiles.WinsysDstFile); ft = new FileTransfer(WinsysTxFiles); ft.LoadFiles(); pmRx = new ProcessMsgDelegateRXRaw(HandleClientCmd); AppName = config.AppName; Logger.Debug($"{config.AppName} Connection init"); if (config.srvSet == null) { Logger.Error($"{config.AppName} Missing Configuration Server Settings"); throw new Exception($"{config.AppName} Missing Configuration Server Settings."); } conn = new UMDServerConnection(config.srvSet, ref sm, rm); conn.Connect(); UMDServer = new UMDManifest(); drillDown = new ManifestDetails(sm, rm, pmRx); }
//public virtual void InitConnections(string umdurl = "localhost", ushort umdport = 81, string winurl="localhost", ushort winport=8181) public virtual void InitConnections(SocketSettings srvSet) { if (winSys == null) { this.winurl = srvSet.clienturl; //winurl; this.winport = srvSet.clientport; // winport; rm = new ReceiveMsgDelegate(ReceiveMessageCB); //Connect to WinSys Server winSys = new ClientSocketConnection(srvSet, ref smWinsys, rm); winSys.Connect(); } if (umdSrv == null) { this.umdurl = srvSet.url; this.umdport = srvSet.port; //Connect to UMD Server umdSrv = new ClientSocketConnection(srvSet, ref smUMDSrv, rm); umdSrv.Connect(); } else { umdSrv.ReInit(ref smUMDSrv); } }
public ManifestDetails(SendMsgDelegate SendMessage, ReceiveMsgDelegate ReceiveMessage, ProcessMsgDelegateRXRaw pm) { sm = SendMessage; rm = ReceiveMessage; }
private async Task ConnectAsync(ReceiveMsgDelegate mp, SocketSettings socSet, WaitHandle connwh = null) { AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnProcessExit; Logger.Info("===================================="); Logger.Info($" STARTING WEBSOCKET {socSet.name} "); Logger.Info(" Manager API Client "); Logger.Info("===================================="); var factory = new Func <ClientWebSocket>(() => new ClientWebSocket { Options = { KeepAliveInterval = TimeSpan.FromSeconds(socSet.keepalive), // Proxy = ... // ClientCertificates = ... } }); if (!bRunning) { try { bRunning = true; addconn(this); var URL = new Uri("ws://" + socSet.url + ":" + socSet.port); using (IWebsocketClient client = new WebsocketClient(URL, factory)) { string received = null; oclient = client; client.Name = name; client.ReconnectTimeoutMs = (int)TimeSpan.FromSeconds(socSet.recontimeout).TotalMilliseconds; client.ErrorReconnectTimeoutMs = (int)TimeSpan.FromSeconds(socSet.errrecontimeout).TotalMilliseconds; client.ReconnectionHappened.Subscribe((Action <ReconnectionType>)((type) => { Logger.Info($"Reconnecting Manager API Client to type: {type} , url: {client.Url} , name: {name} {client.Name}"); })); client.DisconnectionHappened.Subscribe((Action <DisconnectionType>)((type) => { Logger.Info($"Disconnection Manager API Client to type: {type} , url: {client.Url}, name {name} {client.Name}"); })); client.MessageReceived.Subscribe((msg) => { try { if (msg.Text != null) { received = msg.Text; Logger.Debug($"Message To Manager API Client From : {received}, name {name} {client.Name}"); } else if (msg.Binary != null) { isaCommand cmd = MsgProcessor.CommandFactory(msg.Binary); if (cmd.command == eCommand.Ping) { Logger.Debug($"Ping To Manager API Client, Reply Pong to {name} {client.Name}"); client.Send(new Command() { command = eCommand.Pong }.ToArray()); } else if (cmd.command == eCommand.Pong) { Logger.Debug($"Manager API Received Pong from {name} {client.Name}"); } else { Logger.Info($"Manager API Received msg from {name} {client.Name}"); mp(cmd); } } } catch (Exception ex) { //isaCommand cmd = MsgProcessor.CommandFactory(msg.Binary); Logger.Error($"Message Received Manager API: " + ex.Message + Environment.NewLine + msg.ToString()); } }); await client.Start(); //new Thread(() => StartSendingPing(client)).Start(); ExitEvent.WaitOne(); } } catch (Exception e) { } finally { rmconn(this); if (connwh != null) { ((AutoResetEvent)connwh).Set(); } } } Logger.Info("===================================="); Logger.Info($" STOPPING WebSocketClient {name} "); Logger.Info(" Manager API Client "); Logger.Info("===================================="); }
public ClientSocketConnection(SocketSettings sockSet, ref SendMsgDelegate sm, ReceiveMsgDelegate rm = null) { Init(sockSet, ref sm, rm); }
public ReceiveMessages(ReceiveMsgDelegate pmd) { cbViewProcessMsg = pmd; }