// --------------- Identification handlers ----------------- void ClientIdentificationRequest() { ClientIdentificationRequestMessage msg = new ClientIdentificationRequestMessage(); msg.userName = user.userName; msg.userId = user.userId; client.Send(ClientIdentificationRequestMessage.ID, msg); Debug.Log("Sent identification request"); }
// --------------- Identification handlers ----------------- void OnServerIdentificationRequest(NetworkMessage netMsg) { ClientIdentificationRequestMessage msg = netMsg.ReadMessage <ClientIdentificationRequestMessage>(); Debug.Log("Server received Identification request from " + msg.userName); User u = null; // Get or create the user identifying if (usersByName.ContainsKey(msg.userName)) // if user already identified { u = usersByName[msg.userName]; } else { u = new User(); usersByName[msg.userName] = u; } u.identify(msg.userName, msg.userId); usersByConnection[netMsg.conn] = u; u.connection = netMsg.conn; ServerIdentificationResponse(u, netMsg.conn); }