コード例 #1
0
        private void OnServerEventRecieve(ExecEventProcData data)
        {
            var handler = ServerEventRecieve;

            if (handler != null)
            {
                handler(this, new ServerEventArgs(data));
            }
        }
コード例 #2
0
        private void ProcessPacket(Packet packet)
        {
            switch (packet.Method)
            {
            case PacketType.SCZero:
                break;

            case PacketType.SCReturnValue:
                _replyes.Enqueue(packet);
                break;

            case PacketType.SCScriptDLLTerminate:
                new Task(OnTerminateRecieve).Start();
                break;

            case PacketType.SCPauseResumeScript:
                new Task(OnStartStopRevieve).Start();
                break;

            case PacketType.SCExecEventProc:
                var eventCode = packet.Data[0];
                var eventType = (EventTypes)packet.Data[1];


                var parameters = new ArrayList();
                using (var stream = new MemoryStream(packet.Data, 2, packet.DataLength - 2))
                    using (var reader = new BinaryReader(stream))
                    {
                        while (stream.Position < stream.Length - 1)
                        {
                            var type = reader.ReadByte();
                            var size = reader.ReadUInt16();
                            switch ((DataType)type)
                            {
                            case DataType.parUnicodeString:
                                parameters.Add(Encoding.Unicode.GetString(reader.ReadBytes(size)));
                                break;

                            case DataType.parInteger:
                                parameters.Add(reader.ReadInt32());
                                break;

                            case DataType.parCardinal:
                                parameters.Add(reader.ReadUInt32());
                                break;

                            case DataType.parBoolean:
                                parameters.Add(reader.ReadBoolean());
                                break;

                            case DataType.parWord:
                                parameters.Add(reader.ReadUInt16());
                                break;

                            case DataType.parByte:
                                parameters.Add(reader.ReadByte());
                                break;
                            }
                        }
                    }


                var data = new ExecEventProcData(eventCode, eventType, parameters);
                new Task(() => OnServerEventRecieve(data)).Start();
                break;

            default:
                throw new Exception("Recieve unknown packet. ID: " + (ushort)packet.Method);
            }
        }
コード例 #3
0
 public ServerEventArgs(ExecEventProcData data)
 {
     Data = data;
 }