protected override void OnExecute(Protocol.GetRoom message, EC.ISession session, Interfaces.IUserAgent agent, Interfaces.ISiqiServer server) { Protocol.RoomInfoDetail result = new Protocol.RoomInfoDetail(); result.Success = true; try { Interfaces.IRoom room = server.GetRoom(message.Room); if (room != null) { result = room.GetInfoDetail(); result.Success = true; } else { result.Success = false; result.Message = "房间不存在!"; } } catch (Exception e_) { result.Success = false; result.Message = e_.Message; } server.Send(result, agent); }
public void OnSay(EC.ISession session, Chat.Say e) { e.Name = session.Channel.Name; e.From = session.Channel.EndPoint.ToString(); foreach (Beetle.Express.IChannel other in session.Application.Server.GetOnlines()) { if (other != session.Channel) { session.Application.Server.Send(e, other); } } }
private Dispatch.MessageToken CreateToken(Protocol.IMessage message, EC.ISession session) { IUserAgent agent = (IUserAgent)session[SESSION_KEY.USER]; if (agent == null) { Console.WriteLine(session.Channel.Status); } return(new Dispatch.MessageToken { Message = message, UserAgent = agent, Server = this, Session = session }); }
protected override void OnExecute(Protocol.SelectDesk message, EC.ISession session, Interfaces.IUserAgent agent, Interfaces.ISiqiServer server) { Interfaces.IRoom room = server.GetRoom(message.Room); if (room != null) { room.AddMessage(message, agent); } else { Protocol.SelectDeskResponse response = new Protocol.SelectDeskResponse(); response.Success = false; response.Message = "所在房间不存在!"; server.Send(response, session); } }
protected override void OnExecute(Protocol.SelectRoom message, EC.ISession session, Interfaces.IUserAgent agent, Interfaces.ISiqiServer server) { Protocol.SelectRoomResponse response = new Protocol.SelectRoomResponse(); response.MsgID = message.MsgID; response.Success = false; IRoom room = server.GetRoom(message.Room); if (room != null) { room.In(agent); response.Success = true; response.Room = room.ID; } else { response.Message = "room not found!"; } server.Send(response, session); }
protected override void OnExecute(Protocol.Login message, EC.ISession session, Interfaces.IUserAgent agent, Interfaces.ISiqiServer server) { Protocol.LoginResponse response = new Protocol.LoginResponse(); response.MsgID = message.MsgID; response.Success = false; try { Interfaces.Data.Model.User user = server.LoginHandler.Login(message.EMail, message.Password); if (user != null) { agent = server.GetUser(message.EMail); if (agent == null) { agent = new UserAgent(user, session); server.AddUser(agent); } else { agent.Session = session; } session[SESSION_KEY.USER] = agent; response.Tokey = message.EMail; response.Success = true; session.Channel.Status = Beetle.Express.ChannelStatus.security; } else { response.Message = "用户名和密码不正确!"; } } catch (Exception e_) { response.Message = e_.Message; } server.Send(response, session); }
protected abstract void OnExecute(T message, EC.ISession session, Interfaces.IUserAgent agent, Interfaces.ISiqiServer server);
protected override void OnExecute(Protocol.ListRoom message, EC.ISession session, Interfaces.IUserAgent agent, Interfaces.ISiqiServer server) { Protocol.ListRoomResponse response = server.ListRoom(); response.MsgID = message.MsgID; server.Send(response, session); }
public UserAgent(Interfaces.Data.Model.User user, EC.ISession session) { Name = user.Name; ID = user.ID; Session = session; }
public void Login(EC.ISession session, Protocol.Login e) { mDispatchFactory.Route(CreateToken(e, session)); }
private Interfaces.IUserAgent GetAgent(EC.ISession session) { return((Interfaces.IUserAgent)session[SESSION_KEY.USER]); }
public void GameAction(EC.ISession session, Protocol.GameAciton e) { mDispatchFactory.Route(CreateToken(e, session)); }
public void GetRoom(EC.ISession session, Protocol.GetRoom e) { mDispatchFactory.Route(CreateToken(e, session)); }
public void Talk(EC.ISession session, Protocol.Talk e) { mDispatchFactory.Route(CreateToken(e, session)); }
public void SelectDesk(EC.ISession session, Protocol.SelectDesk e) { mDispatchFactory.Route(CreateToken(e, session)); }