/** * 初始化 */ public bool Initialize(Tools.Logger logger, AddQueueDelegate AddQueue) { bool ret = false; try { if (LoadingConfig()) { this.logger = logger; this.AddQueue = AddQueue; wsServer = new WebSocketServer($"ws://{serverIp}:{serverPort}"); wsServer.AddWebSocketService(serviceName, () => new Handler(SaveLog, AddJob)); wsServer.Start(); if (wsServer.IsListening) { ret = true; SaveLog($"[Info] Create Client Handler Success"); Console.WriteLine("[Info] Listening on port {0}, and providing WebSocket services:", wsServer.Port); foreach (var path in wsServer.WebSocketServices.Paths) { Console.WriteLine("- {0}", path); } } } else { SaveLog($"[Error] Create Client Handler Fail"); } } catch (Exception ex) { SaveLog($"[Error] ClientHandler::Initialize, Catch Msg: {ex.Message}"); } return(ret); }
/// <summary> /// 初始化 /// </summary> /// <returns> 是否初始化成功</returns> public bool Initialize(Tools.Logger logger, AddQueueDelegate addQueue) { bool ret = false; try { this.logger = logger; this.addQueue = addQueue; ret = true; } catch (Exception ex) { Console.WriteLine($"{ex.Message}"); SaveLog("[Error] gRpcImpl::Initialize, Initialize Fail"); } return(ret); }
public Handler(LogDelegate log, AddQueueDelegate AddQueue) { this.SaveLog = log; this.AddQueue = AddQueue; }