/// <summary> /// 调用方法 /// </summary> /// <param name="client"></param> /// <param name="reqMsg"></param> /// <returns></returns> public ResponseMessage CallMethod(IScsServerClient client, RequestMessage reqMsg) { //创建Caller; var caller = CreateCaller(client, reqMsg); //设置上下文 SetOperationContext(client, caller); try { //处理状态服务 if (reqMsg.ServiceName == typeof(IStatusService).FullName) { var s = ParseService(reqMsg); //调用服务 return s.CallService(reqMsg); } else { //创建服务 var service = CreateService(reqMsg); //启动计时 var watch = Stopwatch.StartNew(); //调用服务 var resMsg = service.CallService(reqMsg); //停止计时 watch.Stop(); //调用参数 var callArgs = new CallEventArgs { Caller = caller, ElapsedTime = watch.ElapsedMilliseconds, Count = resMsg.Count, Error = resMsg.Error, Value = resMsg.Value }; //响应计数 NotifyEventArgs(callArgs); //如果是Json方式调用,则需要处理异常 if (resMsg.IsError && reqMsg.InvokeMethod) { resMsg.Error = new ApplicationException(callArgs.Error.Message); } return resMsg; } } finally { //初始化上下文 OperationContext.Current = null; } }
/// <summary> /// Raises ClientDisconnected event. /// </summary> /// <param name="client">Disconnected client</param> protected virtual void OnClientDisconnected(IScsServerClient client) { var handler = ClientDisconnected; if (handler != null) { handler(this, new ServerClientEventArgs(client)); } }
public Connection(IScsServerClient client, bool isValid) { IsValid = isValid; Client = client; Client.WireProtocol = new GameProtocol(); Client.Disconnected += Client_Disconnected; Client.MessageReceived += Client_MessageReceived; }
private void p4_tcp_handler(IScsServerClient sc, Cmd cmd) { switch (cmd.id) { case CmdType.Get_All_Ready_Users_Cmd: OnGetAllReadyUsers(sc, cmd as GetAllReadyUsersCmd); break; case CmdType.Get_Changed_Ready_Users_Cmd: OnGetChangedReadyUsers(sc, cmd as GetChangedReadyUsersCmd); break; } }
public ServerClientDictItem(IScsServerClient sc, int life_number) { if (sc == null) { throw new ArgumentException("ServerClient构造参数不能为null."); } this.ServerClient = sc; this.RemainLifeNumber = life_number; this.SenderName = null; }
public string GetIpOfClient(IScsServerClient client) { var all = client.RemoteEndPoint.ToString(); var ipStart = all.IndexOf("//"); var ipWithPort = all.Substring(ipStart + 2); var portStart = ipWithPort.IndexOf(":"); var ip = ipWithPort.Remove(portStart); return(ip); }
public HiveCommunicationServerClient(IScsServerClient pClientInformation, int pMinimumTime, bool pAllowInput, bool pShareSceens) { this.ClientInformation = pClientInformation; this.MinimumTime = pMinimumTime; this.AllowInput = pAllowInput; this.ShareScreens = pShareSceens; this.AllowedKeys = new List <Keys>(); this._countdownTimer = new Timer(); this._countdownTimer.Tick += this.CountdownTimerOnTick; }
public OuterNetworkConnection(IScsServerClient client) { Client = client; Client.WireProtocol = new OuterWireProtocol(); Client.Disconnected += OnDisconnected; Client.MessageReceived += OnMessageReceived; OuterConnections.Add(this); }
/// <summary> /// Raises ClientDisconnected event. /// /// </summary> /// <param name="client">Disconnected client</param> protected virtual void OnClientDisconnected(IScsServerClient client) { EventHandler <ServerClientEventArgs> eventHandler = this.ClientDisconnected; if (eventHandler == null) { return; } eventHandler((object)this, new ServerClientEventArgs(client)); }
public BaseServerClient(string token, IScsServerClient client, Server server, string detail = "") { _token = token; _detail = detail; _client = client; _server = server; _client.MessageReceived += this.Client_MessageRecevied; _client.Disconnected += this.Client_DisconnectHadnle; }
public void Run(IScsServerClient client, List <string> parameters, string messageId) { var sender = new ServerSender(client); if (!Utils.Instance.IsActiveLogin(client)) { return; } sender.GetRooms(DataSingleton.Instance.Rooms.GetAllItems(), messageId); }
public CallbackInvocationHandler(Type callType, IScsServerClient client) { this.callType = callType; this.client = client; //启用线程进行数据推送 Thread thread = new Thread(DoSend); thread.IsBackground = true; thread.Start(); }
public NetSession(IScsServerClient client) { this.Session = client; this.Session.WireProtocol = new AuthProtocol(); this.Session.Disconnected += OnDisconnected; this.Session.MessageReceived += OnMessageReceived; Log.Info("Create Session : " + this.Session.GetHashCode()); }
public OuterNetworkConnection(IScsServerClient client) { Client = client; Client.WireProtocol = new OuterWireProtocol(); Client.Disconnected += OnDisconnected; Client.MessageReceived += OnMessageReceived; OuterConnections.Add(this); }
void p5_tcp_server_MessageReceived(IScsServerClient sc, Cmd cmd) { EzLogger.GlobalLogger.debug("message sender = " + cmd.sender_name ?? ""); //根据cmd.sender_name设置各个远程设备状态 //todo //p5必须响应的其它命令 //todo }
public CallbackInvocationHandler(Type callType, IScsServerClient client) { this.callType = callType; this.client = client; //启用线程进行数据推送 Thread thread = new Thread(DoSend); thread.IsBackground = true; thread.Start(); }
public Connection(IScsServerClient client, bool isValid) { IsValid = isValid; Client = client; Client.WireProtocol = new GameProtocol(); Client.Disconnected += Client_Disconnected; Client.MessageReceived += Client_MessageReceived; Connections.Add(this); }
internal OperationContext(IScsServerClient client, Type callbackType) { this.client = client; this.callbackType = callbackType; if (client != null) { var ep = client.RemoteEndPoint as ScsTcpEndPoint; this.endPoint = new IPEndPoint(IPAddress.Parse(ep.IpAddress), ep.TcpPort); } }
private void ServerOnNewMessage(ScsTextMessage pMessage, IScsServerClient pClient) { try { if (this.LogAll == true) { InputHiveServerForm.LoggingQueue.Enqueue(String.Format( "{0} Received message from: {1} - {2} ", DateTime.Now, this.Server.FindClient(pClient.ClientId), pMessage.Text)); } string[] lvSplit = pMessage.Text.Split(':'); switch (lvSplit[0].ToLower()) { case "username": if (this.Server.FindClient(lvSplit[1]) == null && lvSplit[1].ToLower() != "server" && !String.IsNullOrWhiteSpace(lvSplit[1])) { this.Server.FindClient(pClient.ClientId).Username = lvSplit[1]; pClient.SendMessage(new ScsTextMessage("username:ok")); this.Server.ChatToAllClients(lvSplit[1] + " joined the server."); InputHiveServerForm.LoggingQueue.Enqueue(String.Format("{0} {1} joined the server.", DateTime.Now, lvSplit[1])); if (this.UpdateClientEvent != null) { this.UpdateClientEvent.Invoke(); } this.UpdateKeyListToClient(this.Server.FindClient(pClient.ClientId), this.DefaultAllowedKeys.ToArray()); this.Server.FindClient(pClient.ClientId).AllowedKeys = new List <Keys>(this.DefaultAllowedKeys); } else { pClient.SendMessage(new ScsTextMessage("username:error")); } break; case "chat": this.Server.ChatToAllClients(string.Format("{0} {1}: {2}", DateTime.Now, this.Server.FindClient(pClient.ClientId).Username, pMessage.Text.Remove(0, 5))); break; case "key": this.SendKey((Keys)Convert.ToInt32(lvSplit[1].Trim()), this.Server.FindClient(pClient.ClientId)); break; default: throw new Exception(); } } catch (Exception lvException) { InputHiveServerForm.LoggingQueue.Enqueue(String.Format( "{0} !-!-! ERROR: Error processing message: {1} from {2}\t\nERROR MESSAGE: {3}", DateTime.Now, pMessage.Text, this.Server.FindClient(pClient.ClientId), lvException.Message)); //throw new Exception("Error processing message:\n" + pMessage.Text + "\n\n" + lvException.Message); } }
private void OnLogin(IScsServerClient sc, LoginCmd cmd) { Thread.Sleep(3000); LoginCmdAck ack = new LoginCmdAck(); ack.RepliedMessageId = cmd.MessageId; ack.sender_name = this_name; ack.status = 0; Helper.tcp_server_send(sc, ack); }
public Connection(IScsServerClient client) { Client = client; Client.WireProtocol = new KeyProtocol(); Client.Disconnected += OnDisconnected; Client.MessageReceived += OnMessageReceived; Client.SendMessage(new KeyMessage { Key = new byte[] { 1, 0, 0, 0 } }); Connections.Add(this); }
public Connection(IScsServerClient client) { this.Client = client; this.Client.WireProtocol = new KeyProtocol(); client.Disconnected += onClientDisconnected; client.MessageReceived += onClientMessageReceived; client.SendMessage(new KeyMessage { Key = new byte[] { 1, 0, 0, 0 } }); Connections.Add(this); }
public virtual void Relink(IScsServerClient client) { _client.MessageReceived -= Client_MessageRecevied; _client.Disconnected -= Client_DisconnectHadnle; _client = client; _client.MessageReceived += Client_MessageRecevied; _client.Disconnected += Client_DisconnectHadnle; this.Online = true; }
public static void tcp_server_send(IScsServerClient server, Cmd cmd) { if (server == null || cmd == null || server.CommunicationState != CommunicationStates.Connected) { return; } lock (server) { try { server.SendMessage(cmd); } catch (System.Exception ex) { EzLogger.GlobalLogger.warning(string.Format("{0}{2}{1}{2}", ex.Message, ex.StackTrace, Environment.NewLine)); } } }
private void OnClientPrintUser(IScsServerClient sc, ClientPrintUserCmd cmd) { Thread.Sleep(3000); ClientPrintUserCmdAck ack = new ClientPrintUserCmdAck(); ack.RepliedMessageId = cmd.MessageId; ack.sender_name = this_name; ack.print_dcm = cmd.print_dcm; ack.print_report = cmd.print_report; ack.print_dcm_ack = 0; ack.print_report_ack = 0; Helper.tcp_server_send(sc, ack); }
private void p2_tcp_handler(IScsServerClient sc, Cmd cmd) { switch (cmd.id) { case CmdType.Query_User_Cmd: OnQueryUser(sc, cmd as QueryUserCmd); break; case CmdType.Server_Print_User_Cmd: OnServerPrintUser(sc, cmd as ServerPrintUserCmd); break; case CmdType.Login_Cmd: OnLogin(sc, cmd as LoginCmd); break; case CmdType.Client_Print_User_Cmd: OnClientPrintUser(sc, cmd as ClientPrintUserCmd); break; } }
private void OnClientPrintUser(IScsServerClient sc, ClientPrintUserCmd cmd) { Thread.Sleep(3000); ClientPrintUserCmdAck ack = new ClientPrintUserCmdAck(); ack.RepliedMessageId = cmd.MessageId; ack.sender_name = this_name; ack.print_dcm = cmd.print_dcm; ack.print_report = cmd.print_report; ack.print_dcm_ack = 0; ack.print_report_ack = 0; Helper.tcp_server_send(sc, ack); }
public void Run(IScsServerClient client, List <string> parameters, string messageId) { var sender = new ServerSender(client); var login = parameters[0]; var password = parameters[1]; try { if (SqlUserCommands.LoginExists(login)) { var hashedPass = Scrypt.Hash(password, SqlUserCommands.GetSalt(login)); if (SqlUserCommands.CheckPassword(hashedPass, login)) { var getUserID = SqlUserCommands.GetUserId(login); var rank = SqlUserCommands.GetUserRank(getUserID); var tmpClient = new ServerClient(client) { Rank = (Rank)rank, Id = getUserID, Username = login, Login = login }; // if (Utils.Instance.IsActiveLogin(client)) //Receiver_Disconnect(null, new ServerReceiverEvents.DisconnectEventArgs(e.Client)); ///TODO DataSingleton.Instance.ServerClients[(int)tmpClient.Client.ClientId] = tmpClient; sender.Success(messageId, tmpClient.Username); SqlUserCommands.AddActionInfo(getUserID, Utils.Instance.GetIpOfClient(client), SqlUserCommands.Actions.Login); } else { sender.Error(messageId); } } else { sender.Error(messageId); } } catch (Exception ex) { Console.WriteLine(ex.Message); sender.Error(messageId); } }
/// <summary> /// 设置上下文 /// </summary> /// <param name="client"></param> /// <param name="caller"></param> private void SetOperationContext(IScsServerClient client, AppCaller caller) { //实例化当前上下文 Type callbackType = null; if (callbackTypes.ContainsKey(caller.ServiceName)) { callbackType = callbackTypes[caller.ServiceName]; } OperationContext.Current = new OperationContext(client, callbackType) { Container = status.Container, Caller = caller }; }
public InternalClient(Guid guid, ILog log, IScsServerClient client, string ip, PacketService packetService, IServer server) { Guid = guid; Log = log; _client = client; IP = ip; _server = server; PacketService = packetService; _client.WireProtocol = new AuthProtocol(); _client.Disconnected += OnTCPDisconnected; _client.MessageReceived += OnReceiveMessage; ThreadExtension.DelayAndExecute(WaitForFirstPacket, WaitTime); }
/// <summary> /// 获取AppCaller /// </summary> /// <param name="client"></param> /// <param name="reqMsg"></param> /// <returns></returns> private AppCaller CreateCaller(IScsServerClient client, RequestMessage reqMsg) { //获取AppPath var appPath = (client.State == null) ? null : (client.State as AppClient).AppPath; //服务参数信息 var caller = new AppCaller { AppPath = appPath, AppName = reqMsg.AppName, IPAddress = reqMsg.IPAddress, HostName = reqMsg.HostName, ServiceName = reqMsg.ServiceName, MethodName = reqMsg.MethodName, Parameters = reqMsg.Parameters.ToString(), CallTime = DateTime.Now }; return(caller); }
private void OnDisconnected(object sender, EventArgs e) { AccountLogic.ClientDisconnected(this); if (Account != null) { Account.Connection = null; } Account = null; if (Player != null) { Player.Connection = null; } Player = null; Buffer = null; Client = null; SendData = null; SendLock = null; }
private void Client_MessageReceived(object sender, MessageEventArgs e) { try { ScsTextMessage lvMessage = e.Message as ScsTextMessage; //Server only accepts text messages if (lvMessage == null) { return; } IScsServerClient lvClient = (IScsServerClient)sender; if (this.NewMessage != null) { this.NewMessage.Invoke(lvMessage, lvClient); } } catch (Exception lvEx) { InputHiveServerForm.LoggingQueue.Enqueue(String.Format( "ERROR: Client_MessageReceived: " + lvEx.Message)); } }
public void Run(IScsServerClient client, List <string> parameters, string messageId) { var sender = new ServerSender(client); var login = parameters[0]; var password = parameters[1]; var email = parameters[2]; try { if (!SqlUserCommands.LoginExists(login)) { var salt = Scrypt.GenerateSalt(); if (SqlUserCommands.CreateUser(login, Scrypt.Hash(password, salt), salt, login)) { sender.Success(messageId); var getUserID = SqlUserCommands.GetUserId(login); SqlUserCommands.AddActionInfo(getUserID, Utils.Instance.GetIpOfClient(client), SqlUserCommands.Actions.Register); } else { sender.Error(messageId); } } else { sender.Error(messageId); //TODO acc exist param } } catch (Exception ex) { Console.WriteLine(ex.Message); sender.Error(messageId); } }
/// <summary> /// 发送消息 /// </summary> /// <param name="client"></param> /// <param name="msgBase"></param> /// <param name="messageId"></param> private void SendMessage(IScsServerClient client, MessageBase msgBase, string messageId) { try { var sendMsg = new ScsResultMessage(msgBase, messageId); //发送消息 client.SendMessage(sendMsg); } catch (Exception ex) { //写异常日志 container.Write(ex); try { msgBase = new ResponseMessage { TransactionId = msgBase.TransactionId, ReturnType = msgBase.ReturnType, ServiceName = msgBase.ServiceName, MethodName = msgBase.MethodName, Parameters = msgBase.Parameters, Error = ex }; var sendMsg = new ScsResultMessage(msgBase, messageId); //发送消息 client.SendMessage(sendMsg); } catch { //写异常日志 container.Write(ex); } } }
private void OnGetAllReadyUsers(IScsServerClient sc, GetAllReadyUsersCmd cmd) { GetAllReadyUsersCmdAck ack = new GetAllReadyUsersCmdAck(); ack.RepliedMessageId = cmd.MessageId; ack.sender_name = this_name; ack.users = new List<ReadyUserItem>(); for (int i = 0; i < 30; i++) { ack.users.Add(new ReadyUserItem() { id = i.ToString(), name = "张三" + i.ToString(), is_male = i % 2 == 0, age = (uint)i + 32, dcm_type = "CT", study_department = "放射科", report_num = 1, dcm_num = 1, desc = "", available = true }); } Helper.tcp_server_send(sc, ack); }
private static void Client_MessageReceived(object sender, MessageEventArgs e) { // Pass received data to the parser IScsServerClient client = sender as IScsServerClient; ScsRawDataMessage message = e.Message as ScsRawDataMessage; if (client != null && message != null && message.MessageData != null) { ClientInfo info = infos[client.ClientId]; if (info != null) { try { info.parser.AppendBytes(message.MessageData); } catch (Exception ex) { // Catch parsing error in order not to close connection to client Console.WriteLine(ex.ToString()); Console.WriteLine(string.Format("Received message: {0}", RFPPFHelper.ByteArrayToHexString(message.MessageData))); } } } }
private void OnQueryUser(IScsServerClient sc, QueryUserCmd cmd) { Thread.Sleep(5000); QueryUserCmdAck ack = new QueryUserCmdAck(); ack.RepliedMessageId = cmd.MessageId; ack.sender_name = this_name; ack.user.id = cmd.user_id; ack.user.name = "李四"; ack.user.is_male = true; ack.user.age = 42; ack.user.dcm_num = 3; ack.user.report_num = 1; ack.dcm_files_number = 3; ack.report_files_number = 1; ack.dcm_files_ready = true; ack.report_files_ready = true; ack.printed_report_times = 0; ack.printed_dcm_times = 2; ack.transfer_dcm_files = false; //todo ack.transfer_report_files = false; //todo Helper.tcp_server_send(sc, ack); }
private void p2_tcp_handler(IScsServerClient sc, Cmd cmd) { switch (cmd.id) { case CmdType.Query_User_Cmd: OnQueryUser(sc, cmd as QueryUserCmd); break; case CmdType.Server_Print_User_Cmd: OnServerPrintUser(sc, cmd as ServerPrintUserCmd); break; case CmdType.Login_Cmd: OnLogin(sc, cmd as LoginCmd); break; case CmdType.Client_Print_User_Cmd: OnClientPrintUser(sc, cmd as ClientPrintUserCmd); break; } }
private void p1_tcp_server_MessageReceived(IScsServerClient sc, Cmd cmd) { try { //心跳消息底层处理过 if (cmd is HeartBeatCmd) return; string sender = cmd.sender_name.ToLower(); if (sender.Contains("p4")) Task.Factory.StartNew(() => p4_tcp_handler(sc, cmd)); else if (sender.Contains("p2")) Task.Factory.StartNew(() => p2_tcp_handler(sc, cmd)); } catch (System.Exception ex) { EzLogger.GlobalLogger.warning(string.Format("{0}{2}{1}{2}", ex.Message, ex.StackTrace, Environment.NewLine)); } }
private void OnQueryUser(IScsServerClient sc, QueryUserCmd cmd) { Thread.Sleep(5000); QueryUserCmdAck ack = new QueryUserCmdAck(); ack.RepliedMessageId = cmd.MessageId; ack.sender_name = this_name; ack.user.id = cmd.user_id; ack.user.name = "李四"; ack.user.is_male = true; ack.user.age = 42; ack.user.dcm_num = 3; ack.user.report_num = 1; ack.dcm_files_number = 3; ack.report_files_number = 1; ack.dcm_files_ready = true; ack.report_files_ready = true; ack.printed_report_times = 0; ack.printed_dcm_times = 2; ack.transfer_dcm_files = false;//todo ack.transfer_report_files = false;//todo Helper.tcp_server_send(sc, ack); }
/// <summary> /// 发送消息 /// </summary> /// <param name="client"></param> /// <param name="msgBase"></param> /// <param name="messageId"></param> private void SendMessage(IScsServerClient client, MessageBase msgBase, string messageId) { try { var sendMsg = new ScsResultMessage(msgBase, messageId); //发送消息 client.SendMessage(sendMsg); } catch (Exception ex) { //写异常日志 container.Write(ex); try { msgBase = new ResponseMessage { TransactionId = msgBase.TransactionId, ReturnType = msgBase.ReturnType, ServiceName = msgBase.ServiceName, MethodName = msgBase.MethodName, Parameters = msgBase.Parameters, Error = ex }; var sendMsg = new ScsResultMessage(msgBase, messageId); //发送消息 client.SendMessage(sendMsg); } catch { //写异常日志 container.Write(ex); } } }
private void OnDisconnected(object sender, EventArgs e) { Buffer = null; Client = null; SendData = null; SendLock = null; }
/// <summary> /// 获取AppCaller /// </summary> /// <param name="client"></param> /// <param name="reqMsg"></param> /// <returns></returns> private AppCaller CreateCaller(IScsServerClient client, RequestMessage reqMsg) { //获取AppPath var appPath = (client.State == null) ? null : (client.State as AppClient).AppPath; //服务参数信息 var caller = new AppCaller { AppPath = appPath, AppName = reqMsg.AppName, IPAddress = reqMsg.IPAddress, HostName = reqMsg.HostName, ServiceName = reqMsg.ServiceName, MethodName = reqMsg.MethodName, Parameters = reqMsg.Parameters.ToString(), CallTime = DateTime.Now }; return caller; }
/// <summary> /// Creates a new ServerClientEventArgs object. /// </summary> /// <param name="client">Client that is associated with this event</param> public ServerClientEventArgs(IScsServerClient client) { Client = client; }
/// <summary> /// Raises ClientDisconnected event. /// </summary> /// <param name="client">Disconnected client</param> protected virtual void OnClientDisconnected(IScsServerClient client) { var handler = ClientDisconnected; if (handler != null) { handler(this, new ServerClientEventArgs(client)); } }
private void p4_tcp_handler(IScsServerClient sc, Cmd cmd) { switch (cmd.id) { case CmdType.Get_All_Ready_Users_Cmd: OnGetAllReadyUsers(sc, cmd as GetAllReadyUsersCmd); break; case CmdType.Get_Changed_Ready_Users_Cmd: OnGetChangedReadyUsers(sc, cmd as GetChangedReadyUsersCmd); break; } }
/// <summary> /// 设置上下文 /// </summary> /// <param name="client"></param> /// <param name="caller"></param> private void SetOperationContext(IScsServerClient client, AppCaller caller) { //实例化当前上下文 Type callbackType = null; if (callbackTypes.ContainsKey(caller.ServiceName)) { callbackType = callbackTypes[caller.ServiceName]; } OperationContext.Current = new OperationContext(client, callbackType) { Container = status.Container, Caller = caller }; }
public ServerClientDictItem(IScsServerClient sc, int life_number) { if (sc == null) throw new ArgumentException("ServerClient构造参数不能为null."); this.ServerClient = sc; this.RemainLifeNumber = life_number; this.SenderName = null; }
/// <summary> /// Creates a new service client object that is used in server-side. /// </summary> /// <param name="serverClient">Underlying server client object</param> /// <param name="requestReplyMessenger">RequestReplyMessenger object to send/receive messages over serverClient</param> /// <returns></returns> public static IScsServiceClient CreateServiceClient(IScsServerClient serverClient, RequestReplyMessenger<IScsServerClient> requestReplyMessenger) { return new ScsServiceClient(serverClient, requestReplyMessenger); }
void p5_tcp_server_MessageReceived(IScsServerClient sc, Cmd cmd) { EzLogger.GlobalLogger.debug("message sender = " + cmd.sender_name ?? ""); //根据cmd.sender_name设置各个远程设备状态 //todo //p5必须响应的其它命令 //todo }
private void OnDisconnected(object sender, EventArgs e) { AccountLogic.ClientDisconnected(this); if (Account != null) Account.Connection = null; Account = null; if (Player != null) Player.Connection = null; Player = null; Buffer = null; Client = null; SendData = null; SendLock = null; }
private void OnLogin(IScsServerClient sc, LoginCmd cmd) { Thread.Sleep(3000); LoginCmdAck ack = new LoginCmdAck(); ack.RepliedMessageId = cmd.MessageId; ack.sender_name = this_name; ack.status = 0; Helper.tcp_server_send(sc, ack); }
public NetworkClient(IScsServerClient client) { _client = client; }
/// <summary> /// Raises ClientDisconnected event. /// /// </summary> /// <param name="client">Disconnected client</param> protected virtual void OnClientDisconnected(IScsServerClient client) { EventHandler<ServerClientEventArgs> eventHandler = this.ClientDisconnected; if (eventHandler == null) return; eventHandler((object)this, new ServerClientEventArgs(client)); }
public static void tcp_server_send(IScsServerClient server, Cmd cmd) { if (server == null || cmd == null || server.CommunicationState != CommunicationStates.Connected) return; lock (server) { try { server.SendMessage(cmd); } catch (System.Exception ex) { EzLogger.GlobalLogger.warning(string.Format("{0}{2}{1}{2}", ex.Message, ex.StackTrace, Environment.NewLine)); } } }
private void OnGetChangedReadyUsers(IScsServerClient sc, GetChangedReadyUsersCmd cmd) { GetChangedReadyUsersCmdAck ack = new GetChangedReadyUsersCmdAck(); ack.RepliedMessageId = cmd.MessageId; ack.sender_name = this_name; ack.users = new List<ReadyUserItem>(); ack.users.Add(new ReadyUserItem() { id = "10", name = "张三", is_male = false, age = 32, dcm_type = "CT", study_department = "放射科", report_num = 1, dcm_num = 1, desc = "删除", available = false }); ack.users.Add(new ReadyUserItem() { id = "33", name = "张三", is_male = false, age = 32, dcm_type = "CT", study_department = "放射科", report_num = 1, dcm_num = 1, desc = "新增", available = true }); Helper.tcp_server_send(sc, ack); }