public void ClientConnected(TcpClientInfo clientInfo, WaitingForVerificationClients waitingForVerificationClients) { log($"{clientInfo.OriginalRemotePoint} (System) Connected", Log.LogLevel.Success); ClientInfo = clientInfo; waitingForVerificationClients.ClientConnected(clientInfo); }
public void ClientConnected(TcpClientInfo clientInfo, PrintDineClientConnectProtocol protocol, WaitingForVerificationClients waitingForVerificationClients) { lock (this) { log($"{clientInfo.OriginalRemotePoint} (Printer): HotelId: {protocol.HotelId} Request Connection", Log.LogLevel.Info); if (!Clients.ContainsKey(protocol.HotelId)) { log($"{clientInfo.OriginalRemotePoint} Printer HotelId {protocol.HotelId} Not Matched", Log.LogLevel.Warning); clientInfo.Close(); return; } KeyValuePair <int, TcpClientInfo> pair = Clients.FirstOrDefault(p => p.Key == protocol.HotelId); if (pair.Value != null) { log($"Printer HotelId {pair.Key} Repeated", Log.LogLevel.Warning); pair.Value.ReadyToReplaceClient = clientInfo; pair.Value.Close(); } else { Clients[pair.Key] = clientInfo; } log($"{clientInfo.OriginalRemotePoint} (Printer of Hotel {protocol.HotelId}) Connected", Log.LogLevel.Success); // 打印存储在打印等待队列中的所有请求 while (WaitedQueue[pair.Key].Count > 0) { BaseTcpProtocol printProtocol = WaitedQueue[pair.Key].Dequeue(); if (printProtocol.Type == TcpProtocolType.PrintDine) { sendPrintDineProtocol(pair.Key, (PrintDineProtocol)printProtocol); } else if (printProtocol.Type == TcpProtocolType.PrintShifts) { sendPrintShiftsProtocol(pair.Key, (PrintShiftsProtocol)printProtocol); } log($"Send Waited Dine of Hotel {pair.Key}", Log.LogLevel.Success); } waitingForVerificationClients.ClientConnected(clientInfo); } }
public void ClientConnected(TcpClientInfo clientInfo, NewDineInformClientConnectProtocol protocol, WaitingForVerificationClients waitingForVerificationClients) { lock (this) { log($"{clientInfo.OriginalRemotePoint} (NewDineInformClient): Guid: {protocol.Guid} Request Connection", Log.LogLevel.Info); if (protocol.Guid == new Guid()) { log($"{clientInfo.OriginalRemotePoint} NewDineInformClient Lack Guid", Log.LogLevel.Warning); clientInfo.Close(); return; } KeyValuePair <NewDineInformClientGuid, TcpClientInfo> pair = Clients.FirstOrDefault(p => p.Key.Guid == protocol.Guid); if (pair.Key == null) { log($"{clientInfo.OriginalRemotePoint} NewDineInformClient Guid {protocol.Guid} Not Matched", Log.LogLevel.Warning); clientInfo.Close(); return; } else { if (pair.Value != null) { log($"NewDineInformClient Guid {pair.Key.Guid} Repeated", Log.LogLevel.Warning); pair.Value.ReadyToReplaceClient = clientInfo; pair.Value.Close(); } else { Clients[pair.Key] = clientInfo; } log($"{clientInfo.OriginalRemotePoint} ({pair.Key.Description}) Connected", Log.LogLevel.Success); } waitingForVerificationClients.ClientConnected(clientInfo); } }