[Server, Client and socket] unkown problem i can't fix

10/20/2014 19:44 abdeen#1
in explanation of my problem i have a client and server apps

server send and receive packet as client do ...

the client sends a login request to the server and if server replied with agree

the main form of client shall be hide and appear another form for the user ..

everything is okay ...

but when i send a packet from the server to the client while user is logged on ... the client don't receive it until the user log out and client went back to the main form

but client send packets any time normally and server receive it as well ..

so any solution ?

Server :

PHP Code:
private void Open_Hash_Minutes_Click(object senderEventArgs e)
        {
            if (
SelectedClient.PC_STATE == Data.Enums.ClientState.Reachable || SelectedClient.PC_STATE == Data.Enums.ClientState.Online)
            {
                
Control control = (Control)sender;
                
int Time int.Parse(control.Text);
                
SetTimeForm LF = new SetTimeForm(SelectedClientCalcTime);
                
DialogResult dr LF.ShowDialog(this);
                if (
dr == System.Windows.Forms.DialogResult.Cancel)
                {
                    
LF.Close();
                }
                else if (
dr == System.Windows.Forms.DialogResult.OK)
                {
                    if (
SelectedClient.PC_STATE == Data.Enums.ClientState.Reachable)
                    {
                        
Network.Packets.LoginOrder LO = new Network.Packets.LoginOrder(truetrueLF.ChoosedTimeData.Enums.User.Guest);
                        
LO.Send(SelectedClient);
                    }
                    else if (
SelectedClient.PC_STATE == Data.Enums.ClientState.Online || SelectedClient.PC_STATE == Data.Enums.ClientState.Paused)
                    {
                        
Network.Packets.EditSession EditSession = new Network.Packets.EditSession(truetrueLF.ChoosedTime);
                        
SelectedClient.Send(EditSession);
                    }
                }
            }
            else 
            {
                
MessageBox.Show("This client is not reachable !""HotCafe Server"MessageBoxButtons.OKMessageBoxIcon.Information);
            }
        } 
PHP Code:
        static void AuthServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
        {
            
Client.State authState = new Client.State(obj.Socket);
            
obj.Connector authState;
        }
        static 
void AuthServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
        {
            if (
obj != null)
            {
                
Client.State client = (Client.State)obj.Connector;
                if (
client != null)
                {
                    
client.Disconnect();
                }
            }
        }
        static 
void AuthServer_AnnounceReceive(byte[] packetInterfaces.ISocketWrapper StO)
        {
            try
            {
                
Client.State client = (Client.State)StO.Connector;
                
client.MF MF;
                
Network.PacketHandler.Handle(packetclient);
            }
            catch (
Exception e)
            {
                
Program.WriteLine(e.ToString());
            }
        } 
Client :

PHP Code:
        public static void Handle(byte[] packetClient.State client)
        {
            if (
packet == null)
                return;
            if (
client == null)
                return;

            
ushort ID BitConverter.ToUInt16(packet0);
            
ushort Length BitConverter.ToUInt16(packet2);

            switch (
ID)
            {
                case 
1003:
                    {
                        
Message message = new Message();
                        
message.Deserialize(packet);
                        if (
message.MESSAGE_CONTENT.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries).Length 0)
                            
message.MESSAGE_CONTENT message.MESSAGE_CONTENT.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries)[0];
                        
Chat(messageclient);
                        break;
                    }
                case 
1005:
                    {
                        
Network.Packets.StartSession StartSession = new Network.Packets.StartSession();
                        
StartSession.Deserialize(packet);
                        
client.Session = new Data.Session(clientStartSession);
                        
client.Session.Start();
                        break;
                    }
                case 
1007:
                    {
                        
Network.Packets.EditSession EditSession = new Network.Packets.EditSession();
                        
EditSession.Deserialize(packet);
                        
client.Session.Edit(EditSession.AddEditSession.Time);
                        break;
                    }
                default:
                    {
                        
client.Send(packet);
                        break;
                    }
            }
        } 
PHP Code:
        public void LogIn(Client.State _client)
        {
            switch (
client.PC_USER)
            {
                case 
Data.Enums.ClientUser.Admin:
                    {
                        
//this.Hide();
                        
OldSize this.Size;
                        
this.Size = new System.Drawing.Size(00);
                        
this.WindowState FormWindowState.Minimized;
                        
HandForm = new HandForm(thisclient);
                        
HandForm.UserForm.AdminControlIsVisible true;
                        
HandForm.UserForm.UpdateStart();
                        
HandForm.ShowDialog(this);
                    }
                    break;
                case 
Data.Enums.ClientUser.Guest:
                    {
                        switch (
client.Session.Limited)
                        {
                            case 
true:
                                {
                                    
//this.Hide();
                                    
OldSize this.Size;
                                    
this.Size = new System.Drawing.Size(00);
                                    
this.WindowState FormWindowState.Minimized;
                                    
HandForm = new HandForm(thisclient);
                                    
HandForm.UserForm.AdminControlIsVisible false;
                                    
HandForm.UserForm.UpdateStart();
                                    
HandForm.ShowDialog(this);
                                    break;
                                }
                            case 
false:
                                {
                                    
//this.Hide();
                                    
OldSize this.Size;
                                    
this.Size = new System.Drawing.Size(00);
                                    
this.WindowState FormWindowState.Minimized;
                                    
HandForm = new HandForm(thisclient);
                                    
HandForm.UserForm.AdminControlIsVisible false;
                                    
HandForm.UserForm.UpdateStart();
                                    
HandForm.ShowDialog(this);
                                    break;
                                }
                        }
                        break;
                    }
            }
        } 
i break pointed handle void in client , but it's don't receive the packet until session is ended
10/20/2014 19:49 Xio.#2
:facepalm:

Atleast show us the code.
10/20/2014 19:55 abdeen#3
what exactly code you want to check ?

i tried to don't hide the main form and just re size it to (0, 0) and minimize it but still my problem is going up ...
10/20/2014 20:10 Best Coder 2014#4
[Only registered and activated users can see links. Click Here To Register...]
10/20/2014 20:19 abdeen#5
Server :

PHP Code:
private void Open_Hash_Minutes_Click(object senderEventArgs e)
        {
            if (
SelectedClient.PC_STATE == Data.Enums.ClientState.Reachable || SelectedClient.PC_STATE == Data.Enums.ClientState.Online)
            {
                
Control control = (Control)sender;
                
int Time int.Parse(control.Text);
                
SetTimeForm LF = new SetTimeForm(SelectedClientCalcTime);
                
DialogResult dr LF.ShowDialog(this);
                if (
dr == System.Windows.Forms.DialogResult.Cancel)
                {
                    
LF.Close();
                }
                else if (
dr == System.Windows.Forms.DialogResult.OK)
                {
                    if (
SelectedClient.PC_STATE == Data.Enums.ClientState.Reachable)
                    {
                        
Network.Packets.LoginOrder LO = new Network.Packets.LoginOrder(truetrueLF.ChoosedTimeData.Enums.User.Guest);
                        
LO.Send(SelectedClient);
                    }
                    else if (
SelectedClient.PC_STATE == Data.Enums.ClientState.Online || SelectedClient.PC_STATE == Data.Enums.ClientState.Paused)
                    {
                        
Network.Packets.EditSession EditSession = new Network.Packets.EditSession(truetrueLF.ChoosedTime);
                        
SelectedClient.Send(EditSession);
                    }
                }
            }
            else 
            {
                
MessageBox.Show("This client is not reachable !""HotCafe Server"MessageBoxButtons.OKMessageBoxIcon.Information);
            }
        } 
PHP Code:
        static void AuthServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
        {
            
Client.State authState = new Client.State(obj.Socket);
            
obj.Connector authState;
        }
        static 
void AuthServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
        {
            if (
obj != null)
            {
                
Client.State client = (Client.State)obj.Connector;
                if (
client != null)
                {
                    
client.Disconnect();
                }
            }
        }
        static 
void AuthServer_AnnounceReceive(byte[] packetInterfaces.ISocketWrapper StO)
        {
            try
            {
                
Client.State client = (Client.State)StO.Connector;
                
client.MF MF;
                
Network.PacketHandler.Handle(packetclient);
            }
            catch (
Exception e)
            {
                
Program.WriteLine(e.ToString());
            }
        } 
Client :

PHP Code:
        public static void Handle(byte[] packetClient.State client)
        {
            if (
packet == null)
                return;
            if (
client == null)
                return;

            
ushort ID BitConverter.ToUInt16(packet0);
            
ushort Length BitConverter.ToUInt16(packet2);

            switch (
ID)
            {
                case 
1003:
                    {
                        
Message message = new Message();
                        
message.Deserialize(packet);
                        if (
message.MESSAGE_CONTENT.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries).Length 0)
                            
message.MESSAGE_CONTENT message.MESSAGE_CONTENT.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries)[0];
                        
Chat(messageclient);
                        break;
                    }
                case 
1005:
                    {
                        
Network.Packets.StartSession StartSession = new Network.Packets.StartSession();
                        
StartSession.Deserialize(packet);
                        
client.Session = new Data.Session(clientStartSession);
                        
client.Session.Start();
                        break;
                    }
                case 
1007:
                    {
                        
Network.Packets.EditSession EditSession = new Network.Packets.EditSession();
                        
EditSession.Deserialize(packet);
                        
client.Session.Edit(EditSession.AddEditSession.Time);
                        break;
                    }
                default:
                    {
                        
client.Send(packet);
                        break;
                    }
            }
        } 
PHP Code:
        public void LogIn(Client.State _client)
        {
            switch (
client.PC_USER)
            {
                case 
Data.Enums.ClientUser.Admin:
                    {
                        
//this.Hide();
                        
OldSize this.Size;
                        
this.Size = new System.Drawing.Size(00);
                        
this.WindowState FormWindowState.Minimized;
                        
HandForm = new HandForm(thisclient);
                        
HandForm.UserForm.AdminControlIsVisible true;
                        
HandForm.UserForm.UpdateStart();
                        
HandForm.ShowDialog(this);
                    }
                    break;
                case 
Data.Enums.ClientUser.Guest:
                    {
                        switch (
client.Session.Limited)
                        {
                            case 
true:
                                {
                                    
//this.Hide();
                                    
OldSize this.Size;
                                    
this.Size = new System.Drawing.Size(00);
                                    
this.WindowState FormWindowState.Minimized;
                                    
HandForm = new HandForm(thisclient);
                                    
HandForm.UserForm.AdminControlIsVisible false;
                                    
HandForm.UserForm.UpdateStart();
                                    
HandForm.ShowDialog(this);
                                    break;
                                }
                            case 
false:
                                {
                                    
//this.Hide();
                                    
OldSize this.Size;
                                    
this.Size = new System.Drawing.Size(00);
                                    
this.WindowState FormWindowState.Minimized;
                                    
HandForm = new HandForm(thisclient);
                                    
HandForm.UserForm.AdminControlIsVisible false;
                                    
HandForm.UserForm.UpdateStart();
                                    
HandForm.ShowDialog(this);
                                    break;
                                }
                        }
                        break;
                    }
            }
        } 
i break pointed handle void in client , but it's don't receive the packet until session is ended
10/20/2014 20:27 Super Aids#6
I would help you if I could read your fucking code.
10/20/2014 20:48 abdeen#7
Quote:
Originally Posted by Super Aids View Post
I would help you if I could read your fucking code.
isn't hard to read my great code lol

just tell me what point you can't get ...
10/20/2014 21:45 pro4never#8
Quote:
Originally Posted by abdeen View Post
isn't hard to read my great code lol

just tell me what point you can't get ...
it's a useless mess like everything you post here.

Stop, just stop.
10/20/2014 21:56 abdeen#9
Quote:
Originally Posted by pro4never View Post
it's a useless mess like everything you post here.

Stop, just stop.
post a solution or Stop , just stop.
10/20/2014 23:21 Xio.#10
He has a point you know? Halloween isnt for another 11 days but your code looks spooky already. Take my candy, just take it and make it stop.
10/20/2014 23:50 Super Aids#11
I don't understand anything.

What about learning the language and name conventions.
10/21/2014 18:52 abdoumatrix#12

posting the codes make it worse. :D
try to organize the codes and more information
and try to breakpoints the handling
10/21/2014 21:09 abdeen#13
Quote:
Originally Posted by abdoumatrix View Post

posting the codes make it worse. :D
try to organize the codes and more information
and try to breakpoints the handling
i am already posted the codes ...

but as i explained the issue it's with forms .. client do no accept packets until i went back to the main form ... and i will put here an code for for explanation ...

10/21/2014 21:24 turk55#14
Enviremont.Exit(0);
10/21/2014 21:39 abdeen#15
Quote:
Originally Posted by turk55 View Post
Enviremont.Exit(0);
this for quit the app .... did you read my issue ?