示例#1
0
 public SROClientContext(SROClientComponent clientComponent)
 {
     this.ClientComponent = clientComponent;
     this.m_shards        = new List <Shard>();
 }
示例#2
0
        private static void StartClient()
        {
            SROClientComponent clientComponent = new SROClientComponent(1)
                                                 .SetFingerprint(new Fingerprint("SR_Client", 0, SecurityFlags.Handshake & SecurityFlags.Blowfish & SecurityFlags.SecurityBytes, string.Empty))
                                                 .SetAccount(new Account("furkan", "1"), "Dentrax")
                                                 .SetCaptcha(string.Empty)
                                                 .SetVersionID(189)
                                                 .SetLocaleID(22)
                                                 .SetClientless(false)
                                                 .SetClientPath("D:\\_Coding-Corner_\\vSRO\\vSRO Client")
                                                 .SetLocalAgentEndPoint(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 25880))
                                                 .SetLocalGatewayEndPoint(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 25779))
                                                 .SetServiceEndPoint(new IPEndPoint(IPAddress.Parse("145.239.106.209"), 15779))
                                                 .SetBindTimeout(100)
                                                 .SetDebugMode(false);

            clientComponent.OnClientStatusChanged += new Action <SROClient, ClientStatusType>(delegate(SROClient client, ClientStatusType status) {
                Console.WriteLine("OnClientStatusChanged : " + status);
            });

            clientComponent.OnAccountStatusChanged += new Action <SROClient, AccountStatusType>(delegate(SROClient client, AccountStatusType status) {
                Console.WriteLine("OnAccountStatusChanged : " + status);
            });

            clientComponent.OnCaptchaStatusChanged += new Action <SROClient, CaptchaStatusType>(delegate(SROClient client, CaptchaStatusType status) {
                Console.WriteLine("OnCaptchaStatusChanged : " + status);
            });

            clientComponent.OnCharacterStatusChanged += new Action <SROClient, CharacterStatusType>(delegate(SROClient client, CharacterStatusType status) {
                Console.WriteLine("OnCharacterStatusChanged : " + status);
            });

            clientComponent.OnLocalSocketStatusChanged += new Action <SocketError>(delegate(SocketError error) {
                if (error == SocketError.Success)
                {
                    Console.WriteLine("LOCAL socket bind SUCCESS! : " + clientComponent.LocalGatewayEndPoint.ToString());
                }
                else
                {
                    Console.WriteLine("LOCAL socket bind FAILED!  : " + error);
                }
            });

            clientComponent.OnServiceSocketStatusChanged += new Action <SROClient, SocketError>(delegate(SROClient client, SocketError error) {
                if (error == SocketError.Success)
                {
                    Console.WriteLine("SERVICE socket connect SUCCESS! : " + clientComponent.ServiceEndPoint.ToString());
                }
                else
                {
                    Console.WriteLine("SERVICE socket connect FAILED!  : " + error);
                }
            });

            clientComponent.OnSocketConnected += new Action <SROClient, bool>(delegate(SROClient client, bool connected) {
                Console.WriteLine("Client connected : " + client.Socket.RemoteEndPoint);
            });

            clientComponent.OnSocketDisconnected += new Action <SROClient, ClientDisconnectType>(delegate(SROClient client, ClientDisconnectType disconnectType) {
                Console.WriteLine("Client disconnected : " + client.IPAddress + " -- Reason : " + disconnectType);
            });

            clientComponent.OnPacketReceived += new Func <SROClient, SROPacket, PacketSocketType, PacketResult>(delegate(SROClient client, SROPacket packet, PacketSocketType socketType) {
                DumpPacket(packet);
                return(new PacketResult(PacketOperationType.NOTHING));
            });

            clientComponent.DOConnect(delegate(bool success, BindErrorType error) {
                if (success)
                {
                    Console.WriteLine("PROGRAM.DOConnect() Gateway SUCCESS");
                }
                else
                {
                    Console.WriteLine("PROGRAM.DOConnect() Gateway FAILED -- Reason : " + error);
                }
            });
        }