예제 #1
0
        protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
        {
            if (Log.IsDebugEnabled)
            {
                Log.DebugFormat(
                    "OnDisconnect: conId={0}, reason={1}, reasonDetail={2}",
                    ConnectionId,
                    reasonCode,
                    reasonDetail);
            }

            if (RoomReference == null)
            {
                return;
            }

            var message = new RoomMessage((byte)GameMessageCodes.RemovePeerFromGame, this);

            RoomReference.Room.EnqueueMessage(message);
            RoomReference.Dispose();
            RoomReference = null;
        }
        private static bool DisposeRoomReference(RoomReference r)
        {
            if (r == null)
            {
                return(true);
            }

            // release the reference to the game
            // the game cache will recycle the game instance if no
            // more refrences to the game are left.
            r.Dispose();
            return(false);
        }