public bool Recieve(BaseMessage message) { if (message is LogonMessage) { CompleteLogonAction?.Invoke(message as LogonMessage); } else if (message is DataMessage) { DataMessage dataMessage = message as DataMessage; if (!recvieverCollection.Contains(dataMessage.MessageID)) { recvieverCollection.Add(new BaseReciever { ID = dataMessage.MessageID }); } BaseReciever currentReciever = recvieverCollection[dataMessage.MessageID]; if (message.MessageType == MTMessageType.DataPackage) { CompleteRecieveMessageAction?.Invoke(message as DataMessage); currentReciever.MessageData.AddRange(dataMessage.DataContainer); currentReciever.MessageLength += dataMessage.DataContainer.Count; } else if (message.MessageType == MTMessageType.EndMessage) { //写服务器记录 CompleteRecieveMessageAction?.Invoke(message as DataMessage); currentReciever.GetResult(); CompleteRecieverAction?.Invoke(currentReciever); //recvieverCollection.Remove(currentReciever); } } return(true); }
private void TestRecieve(BaseReciever test) { Console.WriteLine(test.GetResult()); }
internal static void Recieve(BaseReciever reciever) { Console.WriteLine(reciever.GetResult()); }