/// Not Override Functions public void heartbeat_start() { new Task(async() => { if (heartbeat_count >= 3) { heartbeat = false; } else { heartbeat_count++; } NcsBuffer buffer = new NcsBuffer(Program.signal_heartbeat_first, Program.SendToClient, Program.MySpace); buffer.push_size(); Send(buffer.write_buffer, 0, buffer.write_offset); await Task.Delay(3000); if ((heartbeat == false) && (heartbeat_count >= 3) || (instance_die == true)) { this.Close(); } else { heartbeat_start(); } if (heartbeat_count >= 3) { heartbeat_count = 0; } }).Start(); }
void NcsServer_NewRequestReceived(NcsUser user, NcsRequestInfo requestInfo) { NcsBuffer buffer = new NcsBuffer(requestInfo.Body); int space_type = buffer.pop_sint16(); int signal = buffer.pop_sint16(); // Send To Server if (requestInfo.Key == Program.SendToServer) { switch (signal) { case Program.signal_heartbeat_first: { NcsBuffer heartbeat_buffer = new NcsBuffer(Program.signal_heartbeat_second, Program.SendToClient, Program.MySpace); heartbeat_buffer.push_size(); user.Send(heartbeat_buffer.write_buffer, 0, heartbeat_buffer.write_offset); user.heartbeat = true; } break; case Program.signal_login: { Console.WriteLine("Login : "******"unvaild : " + signal); } break; } } // Send To Client else if (requestInfo.Key == Program.SendToClient) { if (user.authentication == true) { switch (space_type) { case Program.MySpace: { foreach (NcsUser index in user_list[user.space]) { if (index != user) { index.Send(requestInfo.Buffer, 0, requestInfo.Buffer.Length); } } } break; case Program.AllSpace: { for (int i = 0; i < Program.space_max; i++) { foreach (NcsUser index in user_list[i]) { if (index != user) { index.Send(requestInfo.Buffer, 0, requestInfo.Buffer.Length); } } } } break; default: { foreach (NcsUser index in user_list[space_type]) { if (index != user) { index.Send(requestInfo.Buffer, 0, requestInfo.Buffer.Length); } } } break; } } } }