コード例 #1
0
ファイル: Reptile.cs プロジェクト: Gaushee/IBCTaker
 public void Send <T>(TakeServerCommand tcmd, T data) where T : class, new()
 {
     ProtocolLogger.WriteLog(data, MainCommand.TakeServer, (ushort)tcmd, LogerType.Info);
     if (socketConnected)
     {
         socket.Send((ushort)MainCommand.TakeServer, (ushort)tcmd, ProtocalSerialize.SerializeObject(data));
     }
 }
コード例 #2
0
ファイル: Reptile.cs プロジェクト: Gaushee/IBCTaker
        public bool OnNCRead(ushort mainCmd, ushort subCmd, string data)
        {
            try
            {
                if ((MainCommand)mainCmd != MainCommand.TakeServer)
                {
                    return(false);
                }

                switch ((TakeServerCommand)subCmd)
                {
                case TakeServerCommand.LoginFault:
                    Console.WriteLine("Central socket connection failed");
                    var tsLoginDtoFault = ProtocalSerialize.UnSerializeObject <TakeServerLoginDto>(data);
                    ProtocolLogger.WriteLog(tsLoginDtoFault, (MainCommand)mainCmd, subCmd, LogerType.Info);
                    break;

                case TakeServerCommand.LoginSuccess:
                    Console.WriteLine("Central socket connection success");
                    var tsLoginDtoSuccess = ProtocalSerialize.UnSerializeObject <TakeServerLoginDto>(data);
                    ProtocolLogger.WriteLog(tsLoginDtoSuccess, (MainCommand)mainCmd, subCmd, LogerType.Info);
                    socketConnected = true;
                    //发送当前比赛管理下 所有的比赛数据(断线重连)
                    //更改为重连后发送所有已经配对的比赛,使其重发完整数据  MatchManager.ForEach(o => o.SendAll());
                    break;

                case TakeServerCommand.MatchLink:
                    var tmLinkDto = ProtocalSerialize.UnSerializeObject <TakeMatchLinkDto>(data);
                    if (tmLinkDto.TakeType != collectorType)
                    {
                        break;
                    }
                    ProtocolLogger.WriteLog(tmLinkDto, (MainCommand)mainCmd, subCmd, LogerType.Info);
                    matchEntityManager.MatchLink(tmLinkDto.SrcMatchID, tmLinkDto.MatchID);
                    break;

                case TakeServerCommand.MatchReset:
                    var tmResetDto = ProtocalSerialize.UnSerializeObject <TakeMatchResetDto>(data);
                    ProtocolLogger.WriteLog(tmResetDto, (MainCommand)mainCmd, subCmd, LogerType.Info);
                    var srcMatchID = matchEntityManager.GetSrcMatchID(tmResetDto.MatchID);
                    matchEntityManager.Reset(srcMatchID);
                    break;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
            }
            return(true);
        }
コード例 #3
0
ファイル: Reptile.cs プロジェクト: Gaushee/IBCTaker
        public bool OnConnect()
        {
            try
            {
                var code = ConfigSingleton.CreateInstance().GetAppConfig <string>("ValidCode");
                Console.WriteLine("Collector Socket Connected Success!");

                //发送登录信息
                TakeServerLoginDto tslLoginDto = new TakeServerLoginDto()
                {
                    TakeType = collectorType, ValidCode = code
                };
                string data = ProtocalSerialize.SerializeObject(tslLoginDto);
                ProtocolLogger.WriteLog <TakeServerLoginDto>(tslLoginDto, MainCommand.TakeServer, (ushort)TakeServerCommand.Login, LogerType.Info);

                socket.Send((ushort)MainCommand.TakeServer, (ushort)TakeServerCommand.Login, data);
                return(true);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
            }
            return(true);
        }