private void initManagers() { _registrationManager = instantiateManager <RegistrationManager>(_registrationManagerPFB); _chatLobbyManager = instantiateManager <ChatLobbyManager>(_chatLobbyManagerPFB); _popupManager = instantiateManager <PopupManager>(_popupManagerPFB); _sceneSelectionManager = instantiateManager <SceneSelectionManager>(_sceneSelectionManagerPFB); _characterSelectionManager = instantiateManager <SceneCharacterSelectionManager>(_characterSelectionManagerPFB); _chatRoomManager = instantiateManager <ChatRoomManager>(_chatRoomManagerPFB); }
public LobbyResponse Lobby(ClientSession session, LobbyRequest request) { session.PublicKey = request.PublicKey; var response = new LobbyResponse(); response.Token = request.Token; try { if (session.HasLobby) { var chatLobby = ChatLobbyManager.GetLobby(session.ChatLobbyId); response.Latitude = chatLobby.Latitude; response.Longitude = chatLobby.Longitude; response.LobbyId = chatLobby.LobbyId; response.MemberPublicKeys = chatLobby.GetMemberKeys(); response.Range = chatLobby.Range; response.Success = true; return(response); } if (ChatLobbyManager.IsLobbyAvailable()) { var chatLobbyId = ChatLobbyManager.GetIdForNextOpenLobby(); var chatLobby = ChatLobbyManager.GetLobby(chatLobbyId); chatLobby.JoinLobby(session); response.Latitude = chatLobby.Latitude; response.Longitude = chatLobby.Longitude; response.LobbyId = chatLobby.LobbyId; response.MemberPublicKeys = chatLobby.GetMemberKeys(); response.Range = chatLobby.Range; response.Success = true; return(response); } else { var chatLobbyId = ChatLobbyManager.CreateLobby(session, request.Longitude, request.Latitude); var chatLobby = ChatLobbyManager.GetLobby(chatLobbyId); response.Latitude = chatLobby.Latitude; response.Longitude = chatLobby.Longitude; response.LobbyId = chatLobby.LobbyId; response.MemberPublicKeys = chatLobby.GetMemberKeys(); response.Range = chatLobby.Range; response.Success = true; return(response); } } catch (Exception exc) { log.Error("Error on LobbyRequest", exc); response.Success = false; return(response); } }
public void Message(ClientSession session, MessageRequest request) { if (session.HasLobby && session.HasChat) { var chatLobby = ChatLobbyManager.GetLobby(session.ChatLobbyId); var chatSession = chatLobby.GetSession(session.ChatSessionId); var data = RequestSerializer.Serialize <RequestBase>(request); if (chatSession != null) { chatSession.SendToSpecificMember(session.RemoteEndPoint, data); } } }
public async Task <SessionResponse> Session(ClientSession session, SessionRequest request) { var response = request.CreateResponse <SessionResponse>(); response.Token = request.Token; if (session.HasChat) { session.LeaveChatSession(); } try { if (ChatLobbyManager.HasMemberSession(session.ChatLobbyId, request.MemberKey)) { response.PublicKey = ChatLobbyManager.JoinSession(session.ChatLobbyId, request.MemberKey, session); response.Success = true; return(response); } else { ChatLobbyManager.OpenSession(session.ChatLobbyId, session); var membersession = ChatLobbyManager.GetLobby(session.ChatLobbyId).GetLobbyMember(request.MemberKey); response.PublicKey = request.MemberKey; //var creatorKey = ChatLobbyManager.JoinSession(session.ChatLobbyId, request.MemberKey, membersession); SessionRequest sessionrequest = new SessionRequest { MemberKey = session.PublicKey }; membersession.Send <SessionRequest>(sessionrequest); response.Success = true; return(response); } } catch (Exception exc) { response.Success = false; return(response); } }