当前位置: 首页>>代码示例>>C#>>正文


C# SocketClient类代码示例

本文整理汇总了C#中SocketClient的典型用法代码示例。如果您正苦于以下问题:C# SocketClient类的具体用法?C# SocketClient怎么用?C# SocketClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SocketClient类属于命名空间,在下文中一共展示了SocketClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        internal void Initialize(SocketClient client, TcpClient tcpClient)
        {
            this.client = client;
            this.tcpClient = tcpClient;

            this.onInitialize ();
        }
开发者ID:xxtbg,项目名称:coredroidservice,代码行数:7,代码来源:ServiceProxy.cs

示例2: Handel

        public static void Handel(SocketClient client, ForgotPasswordRequest request)
        {
            var reply = new LoginResponse();
            try
            {
                var user = AccountRepository.GetAccount(null, request.Email);
                if (user != null)
                {
                    if (user.Locked)
                        reply.ResponseType = LoginResponseType.AccountLocked;

                    else if (user.Verified)
                    {
                        user.Locked = true;
                        user.Verified = false;
                        user.Verificationcode = Guid.NewGuid().ToString();
                        reply.AccountId = user.Accountid;
                        reply.ResponseType = LoginResponseType.ResetSent;
                        EmailSender.SendRestEmail(user);
                        BaseRepository.Update(user);
                    }
                    else
                        reply.ResponseType = LoginResponseType.AccountNotVerified;
                }
                else
                    reply.ResponseType = LoginResponseType.ResetInvalid;

            }
            catch (Exception e)
            {
                reply.ResponseType = LoginResponseType.DatabaseError;
                Logger.Error(e.Message);
            }
            client.Send(reply);
        }
开发者ID:Smallxmac,项目名称:TicTacToeGame,代码行数:35,代码来源:ForgotPasswordRequest.cs

示例3: ChannelSelect

        public static void ChannelSelect(byte[] packet, SocketClient sockstate)
        {
            CMSG_CHANNEL_SELECT cpkt = (CMSG_CHANNEL_SELECT)packet;
            String SqrName = cpkt.SqrName;

            lock (Program.SquareList)
            {
                for (int i = 0; i < Program.SquareList.Count; ++i)
                {
                    if (Program.SquareList[i].Name == SqrName)
                    {
                        SMSG_CHANNEL_SELECT spkt = new SMSG_CHANNEL_SELECT(Program.SquareList[i], sockstate.SelectedChar);
                        SMSG_SEND_SESSION sessionPkt = new SMSG_SEND_SESSION(sockstate.SelectedChar);

                        try
                        {
                            // notify world
                            Program.SquareList[i].Socket.Client.Socket.Send(sessionPkt.Stream);
                        }
                        catch(Exception)
                        {
                            Logger.Log(Logger.LogLevel.Access, "World Server", "Server {0} not responding", Program.SquareList[i].Name);
                            Program.SquareList.RemoveAt(i);
                        }

                        // notify client
                        sockstate.Client.PacketQueue.Enqueue(spkt.Stream);

                        break;
                    }
                }
            }
        }
开发者ID:mabinogidev,项目名称:mabinogi-development,代码行数:33,代码来源:Client.Channel.cs

示例4: Login

        public static void Login(byte[] packet, SocketClient sockstate)
        {
            String Username;
            String Password;

            CMSG_ACCOUNT_LOGIN cpkt = (CMSG_ACCOUNT_LOGIN)packet;
            Username = cpkt.Username;
            Password = cpkt.Password;

            Regex countPattern = new Regex("NHN_P_LOGIN=(.+);");
            Match m1 = countPattern.Match(Password);
            Password = m1.Groups[1].ToString();

            // authenticate
            SMSG_ACCOUNT_LOGIN accPkt = Database.Login(Username, Password, sockstate);
            sockstate.Account.Username = Username;
            sockstate.Client.PacketQueue.Enqueue(accPkt.Stream);

            if (accPkt.LoginSuccess == true)
            {
                Logger.Log(Logger.LogLevel.Access, "Authentication", "Login accepted for user : {0} ", sockstate.Account.Username);

                // send login options
                SMSG_ACCOUNT_OPTIONS optionsPkt = new SMSG_ACCOUNT_OPTIONS();
                optionsPkt.CharSlot = sockstate.Account.Options;
                optionsPkt.CharUnlock = sockstate.Account.Options;
                sockstate.Client.PacketQueue.Enqueue(optionsPkt.Stream);

                // send character list
                List<Structures.Mobile> Characters = Database.CharacterList(sockstate.Account.AID);
                sockstate.Account.Characters = Characters;
                SMSG_CHARACTER_LIST charlistPkt = new SMSG_CHARACTER_LIST(Characters);
                sockstate.Client.PacketQueue.Enqueue(charlistPkt.Stream);
            }
        }
开发者ID:mabinogidev,项目名称:mabinogi-development,代码行数:35,代码来源:Client.Authentication.cs

示例5: SentPacket

 /// <summary>
 /// Called when the packet is sent.
 /// </summary>
 /// <param name="p">The packet that was sent.</param>
 public void SentPacket(Packet p, SocketClient client)
 {
     lock (syncSentPackets)
     {
         sentPackets.AddLast(new PacketSenderPair(p, client));
     }
 }
开发者ID:Wotuu,项目名称:RTS_XNA_v2,代码行数:11,代码来源:PacketProcessor.cs

示例6: CharacterSelect

        public static void CharacterSelect(byte[] packet, SocketClient sockstate)
        {
            String Name;
            int CID = 0;
            bool loginsuccess = true;

            CMSG_CHARACTER_SELECT cpkt = (CMSG_CHARACTER_SELECT)packet;
            Name = cpkt.Name;

            foreach(Mobile character in sockstate.Account.Characters)
            {
                if (character.Name == Name)
                {
                    CID = character.CID;
                    loginsuccess = true;
                }
            }

            if (loginsuccess == true)
            {
                SMSG_CHARACTER_SELECT spkt = new SMSG_CHARACTER_SELECT(Name);
                sockstate.Client.PacketQueue.Enqueue(spkt.Stream);

                SMSG_CHANNEL_SLIME slimePkt = new SMSG_CHANNEL_SLIME();
                sockstate.Client.PacketQueue.Enqueue(slimePkt.Stream);

                sockstate.SelectedChar = CID;
            }
            else
            {
                Logger.Log(Logger.LogLevel.Error, "Hack Detection", "Account: {0} - Invalid Select Character Name: {1}", sockstate.Account.Username, Name);
                sockstate.Disconnect();
            }
        }
开发者ID:LuJie,项目名称:avalon,代码行数:34,代码来源:Client.Character.cs

示例7: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SocketClient client = new SocketClient();
            string resposta;
            client.Connect("10.20.2.124", 6654);
            client.Send("nomejogador/" + txtblock1.Text + "/" + txtblock2.Text);
            resposta = client.Receive();
            /*if (resposta.StartsWith("<ERRO>"))
            {
                MessageBox.Show(resposta);
            }*/

            if (resposta == "naocadastrado")
            {
                MessageBox.Show("Cliente não cadastrado ou senha inválida!");
            }
            else if (resposta == "naook")
            {
                MessageBox.Show("Cliente já está logado no sistema!");
            }
            else
            {
                NavigationService.Navigate(new Uri("/Menu.xaml", UriKind.RelativeOrAbsolute));
            }

        }
开发者ID:Bonei,项目名称:general-ifrn,代码行数:26,代码来源:MainPage.xaml.cs

示例8: IsConnectedTest

 public void IsConnectedTest()
 {
     SocketClient target = new SocketClient(); // TODO: 初始化为适当的值
     bool actual;
     actual = target.IsConnected;
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:7,代码来源:SocketClientTest.cs

示例9: ConnectHandleManagerTest

 public void ConnectHandleManagerTest()
 {
     SocketClient target = new SocketClient(); // TODO: 初始化为适当的值
     ConnectHandleManager actual;
     actual = target.ConnectHandleManager;
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:7,代码来源:SocketClientTest.cs

示例10: ChannelPrevious

 public static void ChannelPrevious(byte[] packet, SocketClient sockstate)
 {
     List<Structures.Mobile> Characters = Database.CharacterList(sockstate.Account.AID);
     sockstate.Account.Characters = Characters;
     SMSG_CHARACTER_LIST charlistPkt = new SMSG_CHARACTER_LIST(Characters);
     sockstate.Client.PacketQueue.Enqueue(charlistPkt.Stream);
 }
开发者ID:mabinogidev,项目名称:mabinogi-development,代码行数:7,代码来源:Client.Channel.cs

示例11: Handle

        public static void Handle(SocketClient client, LoginResponse response)
        {
            if (response.ResponseType == LoginResponseType.AccountNotVerified)
                EmailSender.SendWelcomeEmail(AccountRepository.GetAccount(response.AccountId));

            if(response.ResponseType == LoginResponseType.AccountInUse)
                Program.OnlineAccounts[response.AccountId].Disconnect();
        }
开发者ID:Smallxmac,项目名称:TicTacToeGame,代码行数:8,代码来源:LoginResponse.cs

示例12: Start

    /* Unity Lifecyle */
    void Start()
    {
        socketClient = new SocketClient("192.168.1.9", 1234, socketReadCallback);

        if(SOCKET_ACTIVE) {
            socketClient.connect();
        }
    }
开发者ID:Noah-Huppert,项目名称:Inertial-Motion-Capture,代码行数:9,代码来源:SocketTransformController.cs

示例13: SocketManager

 static SocketManager()
 {
     //初始化数据包缓冲区,并设置了最大数据包尽可能的大 
     BuffListManger = new ZYNetRingBufferPool(400000); 
     client=new SocketClient();
     client.DataOn += new DataOn(client_DataOn);
     client.Disconnection += new ExceptionDisconnection(client_Disconnection);
 }
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:8,代码来源:SocketManager.cs

示例14: SocketManager

 static SocketManager()
 {
     Stream = new ZYNetBufferReadStreamV2(40960);
     client = new SocketClient();
     client.BinaryInput += new ClientBinaryInputHandler(client_BinaryInput);
     client.ErrorLogOut += new ErrorLogOutHandler(client_ErrorLogOut);
     client.MessageInput += new ClientMessageInputHandler(client_MessageInput);
 }
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:8,代码来源:SocketManager.cs

示例15: u3dclient

    public u3dclient()
    {



        register_function();
        socket_client = new SocketClient(1048576, 1048576, 131072, null, new MessageHandler(MessageClient),
            new CloseHandler(CloseClient), new ErrorHandler(ErrorClient), new ConnectHandler(on_connect));
    }
开发者ID:kingstop,项目名称:crashmo,代码行数:9,代码来源:U3dSocketClient.cs


注:本文中的SocketClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。