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 :
Client :
i break pointed handle void in client , but it's don't receive the packet until session is ended
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 sender, EventArgs 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(SelectedClient, Calc, Time);
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(true, true, LF.ChoosedTime, Data.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(true, true, LF.ChoosedTime);
SelectedClient.Send(EditSession);
}
}
}
else
{
MessageBox.Show("This client is not reachable !", "HotCafe Server", MessageBoxButtons.OK, MessageBoxIcon.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[] packet, Interfaces.ISocketWrapper StO)
{
try
{
Client.State client = (Client.State)StO.Connector;
client.MF = MF;
Network.PacketHandler.Handle(packet, client);
}
catch (Exception e)
{
Program.WriteLine(e.ToString());
}
}
PHP Code:
public static void Handle(byte[] packet, Client.State client)
{
if (packet == null)
return;
if (client == null)
return;
ushort ID = BitConverter.ToUInt16(packet, 0);
ushort Length = BitConverter.ToUInt16(packet, 2);
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(message, client);
break;
}
case 1005:
{
Network.Packets.StartSession StartSession = new Network.Packets.StartSession();
StartSession.Deserialize(packet);
client.Session = new Data.Session(client, StartSession);
client.Session.Start();
break;
}
case 1007:
{
Network.Packets.EditSession EditSession = new Network.Packets.EditSession();
EditSession.Deserialize(packet);
client.Session.Edit(EditSession.Add, EditSession.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(0, 0);
this.WindowState = FormWindowState.Minimized;
HandForm = new HandForm(this, client);
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(0, 0);
this.WindowState = FormWindowState.Minimized;
HandForm = new HandForm(this, client);
HandForm.UserForm.AdminControlIsVisible = false;
HandForm.UserForm.UpdateStart();
HandForm.ShowDialog(this);
break;
}
case false:
{
//this.Hide();
OldSize = this.Size;
this.Size = new System.Drawing.Size(0, 0);
this.WindowState = FormWindowState.Minimized;
HandForm = new HandForm(this, client);
HandForm.UserForm.AdminControlIsVisible = false;
HandForm.UserForm.UpdateStart();
HandForm.ShowDialog(this);
break;
}
}
break;
}
}
}