[HELP] Packet Handler

12/07/2008 21:33 sherwin9#1
Hey i get this error

Code:
        
public void GamePacketHandler(object Sender, HybridSocket Socket)
        {
            try
            {
                Socket Sock = Socket.WinSock;
                IPEndPoint IPE = (IPEndPoint)Sock.RemoteEndPoint;
                string Ip = Convert.ToString(IPE.Address);
                int Port = IPE.Port;

                byte[] Data = Socket.Packet;

                if (Socket.Wrapper != null)
                {
                    Client Client = (Client)Socket.Wrapper;
                    [color=red]Client.GetPacket(Data);[/red]
What's wrong with the red highlited line?
12/07/2008 21:37 Ian*#2
Quote:
Originally Posted by sherwin9 View Post
Hey i get this error

Code:
        
public void GamePacketHandler(object Sender, HybridSocket Socket)
        {
            try
            {
                Socket Sock = Socket.WinSock;
                IPEndPoint IPE = (IPEndPoint)Sock.RemoteEndPoint;
                string Ip = Convert.ToString(IPE.Address);
                int Port = IPE.Port;

                byte[] Data = Socket.Packet;

                if (Socket.Wrapper != null)
                {
                    [B]Client Client = (Client)Socket.Wrapper;[/B]
                    [color=red]Client.GetPacket(Data);[/red]
What's wrong with the red highlited line?
Okay, two things.. did you write a function for GetPacket? if not it doesn't do anything... and having "Client Client" would probably cause errors, make sure it's supposed to bel ike that.. more than likely it shouldn't be.
12/07/2008 21:48 tanelipe#3
It trys to access the static method of 'Client' class, not your variables method.
12/07/2008 21:56 sherwin9#4
k thnx guys iīm going to try it out now

EDIt/

it didnīt work look, this is the whole packet handler:

Code:
        public void GamePacketHandler(object Sender, HybridSocket Socket)
        {
            try
            {
                Socket Sock = Socket.WinSock;
                IPEndPoint IPE = (IPEndPoint)Sock.RemoteEndPoint;
                string Ip = Convert.ToString(IPE.Address);
                int Port = IPE.Port;

                byte[] Data = Socket.Packet;

                if (Socket.Wrapper != null)
                {
                    Client Client = (Client)Socket.Wrapper;
                    [color=red]Client.GetPacket(Data);[/color]
                }                
                else
                {
                    Cryptographer TempCrypto = new Cryptographer();
                    TempCrypto.Decrypt(ref Data);

                    if (Data[0] == 0x1c && Data[1] == 0x00 && Data[2] == 0x1c && Data[3] == 0x04)
                    {
                        ulong Keys = Data[11];
                        Keys = (Keys << 8) | Data[10];
                        Keys = (Keys << 8) | Data[9];
                        Keys = (Keys << 8) | Data[8];
                        Keys = (Keys << 8) | Data[7];
                        Keys = (Keys << 8) | Data[6];
                        Keys = (Keys << 8) | Data[5];
                        Keys = (Keys << 8) | Data[4];

                        AuthBinder AB2 = (AuthBinder)KeyClients[Keys];
                        KeyClients.Remove(Keys);

                        Client ThisClient = AB2.Client;

                        Socket.Wrapper = ThisClient;

                        string Account = AB2.Acc;

                        ThisClient.Crypto = TempCrypto;

                        ThisClient.Crypto.SetKeys(new byte[4] { Data[11], Data[10], Data[9], Data[8] }, new byte[4] { Data[7], Data[6], Data[5], Data[4] });
                        ThisClient.Crypto.EnableAlternateKeys();

                        ThisClient.MessageId = Rand.Next(50000);
                        ThisClient.ListenSock = Socket;
                        ThisClient.GetIPE();

                        
                        if (AB2.Auth == 1)
                        {
                            ThisClient.MyChar = new Character();
                            ThisClient.MyChar.MyClient = ThisClient;
                            ThisClient.Account = Account;
                            Database.GetCharInfo(ThisClient.MyChar, Account);

                            ThisClient.SendPacket(MyPackets.LanguageResponse((uint)ThisClient.MessageId));
                            ThisClient.SendPacket(MyPackets.CharacterInfo(ThisClient.MyChar));
                            ThisClient.SendPacket(MyPackets.AfterChar());

                            if (!World.AllChars.Contains(ThisClient.MyChar.UID))
                            {
                                World.AllChars.Add(ThisClient.MyChar.UID, ThisClient.MyChar);
                            }
                            else
                            {
                                ThisClient.MyChar = null;
                                ThisClient = null;
                                return;
                            }
                            Database.ChangeOnlineStatus(ThisClient.Account, 1);
                        }
                        else if (AB2.Auth == 2)
                        {
                            ThisClient.SendPacket(MyPackets.NewCharPacket(ThisClient.MessageId));
                        }
                        else
                        {
                            ThisClient.Drop();
                        }
                    }
                }
            }
            catch (Exception Exc) { WriteLine(Exc.ToString()); }
        }
12/07/2008 22:01 tanelipe#5
Replace this
Code:
 
Client Client = (Client)Socket.Wrapper;
Client.GetPacket(Data);
with something like this :

Code:
 Client Temp = (Client)Socket.Wrapper;
Temp.GetPacket(Data);
12/07/2008 22:04 sherwin9#6
@tanelipe
I think it worked checking it out now, still don't have errors so i guess it works ty :D +thanks ;)

-EDIT
I'm going to sleep, lets see what errors i get tomorrow lol..

-EDIT 2
Sorry it didn't work :S it gives me standard errors, they come back all the time.. maybe someone could check it for me tomorrow on teamviewer? it's 22:00 over here. tomorrow around 13:15 i'll be back online. BYE
12/07/2008 22:08 Korvacs#7
Theres no reason that shouldnt have worked, did you recompile?
12/08/2008 00:45 tanelipe#8
Ok so... how about you tell what the error is? I've ruled out the logical one.
12/08/2008 01:44 tao4229#9
It's not that line, you're getting errors on something wrong in the method of Client.ReceivePacket(byte[] Data)

I don't think he's talking about compiler errors, he's talking about exceptions.
12/08/2008 13:49 sherwin9#10
Hmmm strange, yesterday i had errors, now i donīt have any :S


Hmm, this errors it gives constantly:

[Only registered and activated users can see links. Click Here To Register...]
12/08/2008 19:21 Korvacs#11
oh your using a server that is multi threaded but still trys to access a hashtable at the same time, gg.
12/08/2008 20:06 sherwin9#12
Yeah, could be xD, how to fix it?
12/08/2008 20:08 Korvacs#13
Search for Hashtable release and read the entire thread