//用户登录游戏 public void Login(string userName) { OperationContext context = OperationContext.Current; IChessServiceCallback callback = context.GetCallbackChannel <IChessServiceCallback>(); User user = new User(userName, callback); UserList.Users.Add(user); callback.ShowLogin(UserList.maxRooms); //发送房间信息 SendRoomsInfoToAllUsers(); }
/// <inheritdoc/> public void Ready(string sessionId, IChessServiceCallback callback) { lock (_queueSyncObj) { var player = _playersQueue.FirstOrDefault(p => p.SessionId == sessionId); if (player == null) { throw new FaultException <SessionNotFoundedException>(new SessionNotFoundedException()); } Player.SetCallback(player, callback); Player.SetActive(player); Player.SetIsReady(player); } }
/// <summary> /// Set callback function. /// </summary> /// <param name="player"><see cref="Player"/> instance.</param> /// <param name="callback">Callback interface.</param> internal static void SetCallback(Player player, IChessServiceCallback callback) { player.Callback = callback; }
public User(string userName, IChessServiceCallback callback) { this.UserName = userName; this.callback = callback; }