public void OnEvent(EventData eventData)
        {
            byte Code = eventData.Code;

            if (!EventDic.ContainsKey(Code))
            {
                return;
            }                                                   // イベント購読者がいない

            DictionaryStreamReader Reader = new DictionaryStreamReader(eventData.Parameters);

            EventDic[Code]?.Invoke(Reader);
        }
        public void OnOperationResponse(OperationResponse operationResponse)
        {
            byte PacketID = operationResponse.OperationCode;

            if (!ResponseHandlers.ContainsKey(PacketID))
            {
                throw new Exception(string.Format("{0} に対応するハンドラがない", ((EPacketID)PacketID).ToString()));
            }

            DictionaryStreamReader Reader = new DictionaryStreamReader(operationResponse.Parameters);

            ResponseHandlers[PacketID]?.Invoke(Reader);
            ResponseHandlers.Remove(PacketID);
        }
Esempio n. 3
0
 /// <summary>
 /// オペレーションを受信した
 /// </summary>
 /// <param name="PacketID">パケットID</param>
 /// <param name="Params">パラメータ</param>
 public void OnRecvOperation(EPacketID PacketID, Dictionary <byte, object> Params)
 {
     if (OperationHandlers.ContainsKey(PacketID))
     {
         DictionaryStreamReader Reader = new DictionaryStreamReader(Params);
         var ResponsePacket            = OperationHandlers[PacketID]?.Invoke(Reader);
         if (ResponsePacket != null)      // ResponsePacketがnullならReportとして扱う
         {
             DictionaryStreamWriter Writer = new DictionaryStreamWriter();
             ResponsePacket.Serialize(Writer);
             var Response = new OperationResponse((byte)ResponsePacket.PacketID, Writer.Dest);
             Parent.SendOperationResponse(Response, new SendParameters());
         }
     }
 }