/// <summary> /// Checks if the the state of peer is set to a reference of a room. /// If a room refrence is present the peer will be removed from the related room and the reference will be disposed. /// Disposing the reference allows the associated room factory to remove the room instance if no more references to the room exists. /// </summary> protected virtual void RemovePeerFromCurrentRoom() { // check if the peer already joined another game if (this.RoomReference != null) { // remove peer from his current game. var message = new RoomMessage((byte)GameMessageCodes.RemovePeerFromGame, this); this.RoomReference.Room.EnqueueMessage(message); // release room reference this.RoomReference.Dispose(); this.RoomReference = null; } }
/// <summary> /// Called when client disconnects. /// Ensures that disconnected players leave the game <see cref = "Room" />. /// The player is not removed immediately but a message is sent to the room. This avoids /// threading issues by making sure the player remove is not done concurrently with operations. /// </summary> protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail) { if (log.IsDebugEnabled) { log.DebugFormat("OnDisconnect: conId={0}, reason={1}, reasonDetail={2}", this.ConnectionId, reasonCode, reasonDetail); } if (this.RoomReference == null) { return; } var message = new RoomMessage((byte)GameMessageCodes.RemovePeerFromGame, this); this.RoomReference.Room.EnqueueMessage(message); this.RoomReference.Dispose(); this.RoomReference = null; }
/// <summary> /// Schedules a broadcast of all changes. /// </summary> private void SchedulePublishChanges() { var message = new RoomMessage((byte)LobbyMessageCode.PublishChangeList); this.schedule = this.ScheduleMessage(message, LobbySettings.Default.LobbyUpdateIntervalMs); }
protected override void OnDisconnect(PhotonHostRuntimeInterfaces.DisconnectReason reasonCode, string reasonDetail) { if (log.IsDebugEnabled) { log.DebugFormat("OnDisconnect: conId={0}, reason={1}, detail={2}", this.ConnectionId, reasonCode, reasonDetail); } if (GameApplication.Instance.AppStatsPublisher != null) { GameApplication.Instance.AppStatsPublisher.DecrementPeerCount(); } if (this.RoomReference == null) { return; } var message = new RoomMessage((byte)GameMessageCodes.RemovePeerFromGame, this); this.RoomReference.Room.EnqueueMessage(message); this.RoomReference.Dispose(); this.RoomReference = null; }
public void SchedulePersist() { var message = new RoomMessage((byte) DiscussionMsgCode.CheckPersistAnnotations); ScheduleMessage(message, ANNOT_PERSIST_PERIOD); }