Register for your free account! | Forgot your password?

You last visited: Today at 12:34

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[HELP] Packet Handler

Discussion on [HELP] Packet Handler within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
sherwin9's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 222
Received Thanks: 27
[HELP] Packet Handler

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?
sherwin9 is offline  
Old 12/07/2008, 21:37   #2
 
Ian*'s Avatar
 
elite*gold: 0
Join Date: Nov 2006
Posts: 805
Received Thanks: 464
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.
Ian* is offline  
Old 12/07/2008, 21:48   #3
 
elite*gold: 20
Join Date: Aug 2005
Posts: 1,734
Received Thanks: 1,001
It trys to access the static method of 'Client' class, not your variables method.
tanelipe is offline  
Old 12/07/2008, 21:56   #4
 
sherwin9's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 222
Received Thanks: 27
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()); }
        }
sherwin9 is offline  
Old 12/07/2008, 22:01   #5
 
elite*gold: 20
Join Date: Aug 2005
Posts: 1,734
Received Thanks: 1,001
Replace this
Code:
 
Client Client = (Client)Socket.Wrapper;
Client.GetPacket(Data);
with something like this :

Code:
 Client Temp = (Client)Socket.Wrapper;
Temp.GetPacket(Data);
tanelipe is offline  
Old 12/07/2008, 22:04   #6
 
sherwin9's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 222
Received Thanks: 27
@tanelipe
I think it worked checking it out now, still don't have errors so i guess it works ty +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
sherwin9 is offline  
Old 12/07/2008, 22:08   #7


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Theres no reason that shouldnt have worked, did you recompile?
Korvacs is offline  
Old 12/08/2008, 00:45   #8
 
elite*gold: 20
Join Date: Aug 2005
Posts: 1,734
Received Thanks: 1,001
Ok so... how about you tell what the error is? I've ruled out the logical one.
tanelipe is offline  
Old 12/08/2008, 01:44   #9
 
elite*gold: 0
Join Date: Feb 2008
Posts: 1,590
Received Thanks: 154
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.
tao4229 is offline  
Old 12/08/2008, 13:49   #10
 
sherwin9's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 222
Received Thanks: 27
Hmmm strange, yesterday i had errors, now i donīt have any :S


Hmm, this errors it gives constantly:

sherwin9 is offline  
Old 12/08/2008, 19:21   #11


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
oh your using a server that is multi threaded but still trys to access a hashtable at the same time, gg.
Korvacs is offline  
Old 12/08/2008, 20:06   #12
 
sherwin9's Avatar
 
elite*gold: 0
Join Date: Oct 2006
Posts: 222
Received Thanks: 27
Yeah, could be xD, how to fix it?
sherwin9 is offline  
Old 12/08/2008, 20:08   #13


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Search for Hashtable release and read the entire thread
Korvacs is offline  
Reply




All times are GMT +1. The time now is 12:34.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.