Example #1
0
        public void ProcessMessage(object message)
        {
            if (this.ID == 0L && !(message is Identify))
            {
                Log <Client> .Logger.ErrorFormat("client should send Identify first : [{0}]", message);

                this.client.Transmit(SerializeWriter.ToBinary <IdentifyFailed>(new IdentifyFailed("GameUI_Heroes_Channel_Error_IdentifyFail")));
                this.client.Disconnect();
                return;
            }
            if (message is Identify)
            {
                Identify identify = message as Identify;
                if (!this.parent.VerifyKey(identify.ID, identify.Key))
                {
                    this.client.Transmit(SerializeWriter.ToBinary <IdentifyFailed>(new IdentifyFailed("GameUI_Heroes_Channel_Error_KeyMismatch")));
                    this.client.Disconnect();
                    return;
                }
                this.ID = identify.ID;
                this.parent.IdentifyClient(this);
            }
            if (this.Player != null && message is ServiceCore.EndPointNetwork.IMessage)
            {
                this.Player.ProcessMessage(message as ServiceCore.EndPointNetwork.IMessage);
            }
        }
Example #2
0
 public void BurnGaugeBroadcast()
 {
     using (BurnDataContext burnDataContext = new BurnDataContext())
     {
         try
         {
             int         num         = burnDataContext.AddAllUserEventCount(new int?(-99), new int?(0), new DateTime?(DateTime.MaxValue));
             BurnJackpot burnJackpot = MMOChannelContents.GetBurnJackpot();
             if (burnJackpot != null)
             {
                 if (this.LatestBurnGauge != num)
                 {
                     this.LatestBurnGauge = num;
                     foreach (KeyValuePair <long, Channel> keyValuePair in this.channels)
                     {
                         Channel       value   = keyValuePair.Value;
                         PacketMessage message = new PacketMessage
                         {
                             Data = SerializeWriter.ToBinary <ServiceCore.EndPointNetwork.BurnGauge>(new ServiceCore.EndPointNetwork.BurnGauge(num, burnJackpot.JackpotStart, burnJackpot.MaxReward))
                         };
                         value.BroadcastToColhenLobby(message);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Log <MMOChannelService> .Logger.Error("burn gauge broadcasting error", ex);
         }
     }
 }
Example #3
0
 public void SendMessage <T>(T message)
 {
     if (this.TcpClient != null)
     {
         this.TcpClient.Transmit(SerializeWriter.ToBinary <T>(message));
     }
 }
Example #4
0
        public void SendNonPipeMessage <T>(T message)
        {
            Packet packet = SerializeWriter.ToBinary <T>(message);

            packet.InstanceId = 0L;
            this.client.Transmit(packet);
        }
Example #5
0
        public static bool EndEvent(string name, string scriptend, string msgend, AdminClientServicePeer peer)
        {
            EventDataContext.StartProcessing();
            Event @event = EventDataContext.GetEvent(name);

            if (@event == null)
            {
                if (peer != null)
                {
                    peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Event is Not Registered ! - \"{0}\"", name))));
                }
                return(false);
            }
            if (scriptend != null)
            {
                @event.EndScript = scriptend;
            }
            if (msgend != null)
            {
                @event.EndMessage = msgend;
            }
            EventDataContext.EndEvent(name);
            EventDataContext.RemoveEvent(name);
            if (peer != null)
            {
                string msg = EventDataContext.SendEventListAndDetail(name, "Event is Ended !", false);
                peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, msg)));
            }
            return(true);
        }
Example #6
0
        public void SendMsg <T>(T msg)
        {
            Console.WriteLine("Sending a {0}", typeof(T));
            Packet p = SerializeWriter.ToBinary <T>(msg);

            client.Transmit(p);
        }
Example #7
0
        public void RegisterTcpClientHolder(Devcat.Core.Net.TcpClient tcpClient)
        {
            tcpClient.ConnectionSucceed += delegate(object sender, EventArgs evt)
            {
                string text = string.Format("[Peer {0}:{1}]", tcpClient.LocalEndPoint.Address.ToString(), tcpClient.LocalEndPoint.Port.ToString());
                Log <DSService> .Logger.WarnFormat("{0} Connect ", text);

                object typeConverter = DSService.Instance.MessageHandlerFactory.GetTypeConverter();
                tcpClient.Transmit(SerializeWriter.ToBinary(typeConverter));
                DSHostConnectionQuery value = new DSHostConnectionQuery();
                tcpClient.Transmit(SerializeWriter.ToBinary <DSHostConnectionQuery>(value));
                TcpClientHolder tcpClientHolder = new TcpClientHolder();
                tcpClientHolder.BindTcpClient(tcpClient);
                tcpClientHolder.TimeoutShedID = Scheduler.Schedule(this.Thread, Job.Create <TcpClientHolder>(new Action <TcpClientHolder>(this.UnregisterTcpClientHolder), tcpClientHolder), 30000);
                this.TcpClientHolders.Add(tcpClientHolder);
            };
            tcpClient.ExceptionOccur += delegate(object sender, EventArgs <Exception> evt)
            {
                string text = string.Format("[Peer {0}:{1}]", tcpClient.LocalEndPoint.Address.ToString(), tcpClient.LocalEndPoint.Port.ToString());
                Log <DSService> .Logger.ErrorFormat("{0} ExceptionOccur", text);

                DSLog.AddLog(-1, null, -1L, -1, "ExceptionOccur", text);
            };
            tcpClient.ConnectionFail += delegate(object sender, EventArgs <Exception> evt)
            {
                string text = string.Format("[Peer {0}:{1}]", tcpClient.LocalEndPoint.Address.ToString(), tcpClient.LocalEndPoint.Port.ToString());
                Log <DSService> .Logger.ErrorFormat("{0} ConnectionFail", text);

                DSLog.AddLog(-1, null, -1L, -1, "ConnectionFail", text);
            };
        }
 public void QueryUnderingList(string Text, long selectedEID)
 {
     if (Text == this.parent.ServicesString)
     {
         this.currentTarget = new EntityGraphIdentifier
         {
             category = "ReportService",
             entityID = (long)EntityGraphNode.ServiceEntityID
         };
         this.peer.Transmit(SerializeWriter.ToBinary <RequestLookUpInfoMessage>(new RequestLookUpInfoMessage("ReportService")));
         return;
     }
     string[] array = Text.Split(this.parent.delim);
     if (array.Length == 3)
     {
         this.currentTarget = new EntityGraphIdentifier
         {
             serviceID = int.Parse(array[1]),
             entityID  = (long)EntityGraphNode.ServiceEntityID
         };
     }
     else
     {
         this.currentTarget = new EntityGraphIdentifier
         {
             serviceID = int.Parse(array[1]),
             entityID  = (long.Parse(array[2]) << 32) + long.Parse(array[3])
         };
     }
     this.peer.Transmit(SerializeWriter.ToBinary <RequestUnderingListMessage>(new RequestUnderingListMessage(this.currentTarget, selectedEID)));
 }
Example #9
0
        public Test()
        {
            this.thread = new JobProcessor();
            this.thread.Start();
            this.host1             = new Acceptor(this.thread);
            this.host2             = new Acceptor(this.thread);
            this.host2.OnAccepted += delegate(Peer peer)
            {
                peer.PipeOpen += delegate(Peer _, Pipe pipe)
                {
                    pipe.PacketReceived += delegate(Packet packet)
                    {
                        Log <Test> .Logger.DebugFormat("receive {0}", packet.Length);
                    };
                };
            };
            this.host1.Start(10000);
            this.host2.Start(10001);
            Peer peer2 = Peer.CreateClient(this.host1, new TcpClient());

            peer2.Connected += delegate(Peer peer)
            {
                peer.InitPipe().SendPacket(SerializeWriter.ToBinary <Test.TestMessage>(new Test.TestMessage
                {
                    Y = "asd"
                }));
            };
            peer2.Connect(new IPEndPoint(IPAddress.Loopback, 10001));
        }
Example #10
0
 public void SendMessage <T>(T message)
 {
     if (this.client.Connected)
     {
         this.client.Transmit(SerializeWriter.ToBinary <T>(message));
     }
 }
Example #11
0
        public static SendPacketUserDS Create <T>(T serializeObject) where T : IMessage
        {
            Log <SendPacketUserDS> .Logger.InfoFormat("SendPacketUserDS create : [{0}]", serializeObject);

            Packet packet = SerializeWriter.ToBinary <T>(serializeObject);

            return(new SendPacketUserDS(packet));
        }
Example #12
0
 public void Send <T>(T msg)
 {
     if (this.thread != Thread.CurrentThread.ManagedThreadId)
     {
         Log <Pipe> .Logger.FatalFormat("Thread Unsafe code Send<T> : [{0} != {1} ({2})]", this.thread, Thread.CurrentThread.ManagedThreadId, typeof(T));
     }
     this.SendPacket(SerializeWriter.ToBinary <T>(msg));
 }
Example #13
0
        public static BroadcastPacket Create <T>(T serializeObject) where T : IMessage
        {
            Log <BroadcastPacket> .Logger.InfoFormat("BroadcastPacket create : [{0}]", serializeObject);

            Packet packet = SerializeWriter.ToBinary <T>(serializeObject);

            return(new BroadcastPacket(packet));
        }
Example #14
0
 public void RequestStopService(string target, bool state)
 {
     this.peer.Transmit(SerializeWriter.ToBinary <AdminRequestEmergencyStopMessage>(new AdminRequestEmergencyStopMessage
     {
         TargetService = target,
         TargetState   = state
     }));
 }
Example #15
0
 public HotSpringInfo(ICollection <HotSpringPotionEffectInfo> hotSpringPotionEffectInfos, int townID)
 {
     this.HotSpringPotionEffectInfos = hotSpringPotionEffectInfos;
     this.binaryMessage = new PacketMessage
     {
         Data = SerializeWriter.ToBinary <HotSpringRequestInfoResultChannelMessage>(new HotSpringRequestInfoResultChannelMessage(this.HotSpringPotionEffectInfos, townID))
     };
 }
Example #16
0
 public void RequestConsoleCommand(string text, bool isServerCommand)
 {
     this.peer.Transmit(SerializeWriter.ToBinary <AdminBroadcastConsoleCommandMessage>(new AdminBroadcastConsoleCommandMessage
     {
         commandString   = text,
         isServerCommand = isServerCommand
     }));
 }
Example #17
0
        private void SendLog()
        {
            string value;

            while (this.tcpClient.Connected && this.logQueue.TryDequeue(out value))
            {
                this.tcpClient.Transmit(SerializeWriter.ToBinary <string>(value));
            }
        }
Example #18
0
 public void RequestKick(string uid, string cid)
 {
     if (cid == "")
     {
         this.peer.Transmit(SerializeWriter.ToBinary <AdminRequestKickMessage>(new AdminRequestKickMessage(uid, true)));
         return;
     }
     this.peer.Transmit(SerializeWriter.ToBinary <AdminRequestKickMessage>(new AdminRequestKickMessage(cid, false)));
 }
Example #19
0
 public void RequestItemFestival(string ItemClass, int Amount, string Message, bool IsCafe)
 {
     this.peer.Transmit(SerializeWriter.ToBinary <AdminItemFestivalEventMessage>(new AdminItemFestivalEventMessage
     {
         Amount    = Amount,
         ItemClass = ItemClass,
         Message   = Message,
         IsCafe    = IsCafe
     }));
 }
Example #20
0
 public void Send <T>(T message)
 {
     lock (this)
     {
         if (this.clientNetwork != null)
         {
             Packet packet = SerializeWriter.ToBinary <T>(message);
             this.clientNetwork.Transmit(packet);
         }
     }
 }
Example #21
0
        public void SendClose()
        {
            if (this.thread != Thread.CurrentThread.ManagedThreadId)
            {
                Log <Pipe> .Logger.FatalFormat("Thread Unsafe code SendClose : [{0} != {1} ({2})]", this.thread, Thread.CurrentThread.ManagedThreadId, this.Tag);
            }
            ClosePipe value = new ClosePipe(this.ID);
            Packet    obj   = SerializeWriter.ToBinary <ClosePipe>(value);

            obj.InstanceId = 0L;
            this.PacketSending(obj);
        }
Example #22
0
 private void server_ClientAccept(object sender, AcceptEventArgs e)
 {
     e.PacketAnalyzer = new MessageAnalyzer();
     e.JobProcessor   = this.thread;
     e.Client.Tag     = new Client(this, e.Client, this.mf);
     this.thread.Enqueue(Job.Create(delegate
     {
         object typeConverter = this.mf.GetTypeConverter();
         e.Client.Transmit(SerializeWriter.ToBinary(typeConverter));
     }));
     Log <Server> .Logger.Info("server_ClientAccepted!");
 }
Example #23
0
 public void SendPingAll()
 {
     lock (Base.SyncRoot)
     {
         RemoteControlSystem.ServerMessage.PingMessage value = new RemoteControlSystem.ServerMessage.PingMessage();
         Packet packet = SerializeWriter.ToBinary <RemoteControlSystem.ServerMessage.PingMessage>(value);
         foreach (ClientServer.Client client in this.RCClientInfo.Values)
         {
             client.Connection.Transmit(packet);
         }
     }
 }
Example #24
0
 public void BurnJackpotBroadcast(long cid)
 {
     foreach (KeyValuePair <long, Channel> keyValuePair in this.channels)
     {
         Channel       value   = keyValuePair.Value;
         PacketMessage message = new PacketMessage
         {
             Data = SerializeWriter.ToBinary <BurnJackpotMessage>(new BurnJackpotMessage(cid))
         };
         value.BroadcastToColhenLobby(message);
     }
 }
Example #25
0
 public void ProcessConsoleCommand(string cmd, string args, AdminClientServicePeer peer)
 {
     if (this._ProcessConsoleCommand(cmd, args, peer, -1))
     {
         peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, string.Format("Console Command Executed ! - \"{0} {1}\"", cmd, args))));
         return;
     }
     if (peer != null)
     {
         peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.ERROR, string.Format("Console Command Failed ! - \"{0} {1}\"", cmd, args))));
     }
 }
Example #26
0
 public static bool ShowEvent(string name, AdminClientServicePeer peer)
 {
     if (peer != null)
     {
         Event @event = EventDataContext.GetEvent(name);
         if (@event != null)
         {
             peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, string.Format("\r\n========== Event Detail ==========\r\nStatus [{0}]\r\n{1}\r\n========== Event Detail ==========", EventDataContext.IsRunning(name) ? "Running" : "Pending", @event.ToStringX()))));
             return(true);
         }
     }
     return(false);
 }
Example #27
0
 public static bool ListEvent(AdminClientServicePeer peer)
 {
     if (peer != null)
     {
         string text = "";
         foreach (Event @event in EventDataContext.Instance.Event)
         {
             text += string.Format("{0} [{1}]\r\n", @event.Name, EventDataContext.IsRunning(@event.Name) ? "Running" : "Pending");
         }
         peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, string.Format("\r\n========== Event List ==========\r\n{0}========== Event List ==========", text))));
         return(true);
     }
     return(false);
 }
Example #28
0
 public Chat(long id, string chatter, string msg)
 {
     this.ID            = id;
     this.Message       = msg;
     this.Chatter       = chatter;
     this.binaryMessage = new PacketMessage
     {
         Data = SerializeWriter.ToBinary <NotifyChat>(new NotifyChat
         {
             Name    = this.Chatter,
             Message = this.Message
         })
     };
 }
Example #29
0
 public void SetFreeTokenMode(bool on, AdminClientServicePeer peer)
 {
     int[]       array  = this.MicroPlayServiceIDs();
     FreeToken[] array2 = new FreeToken[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         array2[i]    = new FreeToken();
         array2[i].On = on;
         base.RequestOperation(array[i], array2[i]);
     }
     if (peer != null)
     {
         peer.Transmit(SerializeWriter.ToBinary <AdminReportNotifyMessage>(new AdminReportNotifyMessage(NotifyCode.SUCCESS, string.Format("Set FreeToken Mode [{0}]", on))));
     }
 }
Example #30
0
 public Megaphone(long id, string chatter, string msg)
 {
     base.ID            = id;
     base.Message       = msg;
     base.Chatter       = chatter;
     this.binaryMessage = new PacketMessage
     {
         Data = SerializeWriter.ToBinary <MegaphoneMessage>(new MegaphoneMessage
         {
             SenderName  = chatter,
             Message     = msg,
             MessageType = 1
         })
     };
 }