public override bool OnHandleMessage(IMessage message, IServerPeer sPeer) { Log.DebugFormat("OnHandleMessage:TexasSitHandler"); var errorParam = new Dictionary <byte, object> { { (byte)ServerParameterCode.PeerId, message.Parameters[(byte)ServerParameterCode.PeerId] }, { (byte)ClientParameterCode.SubOperationCode, message.Parameters[(byte)ClientParameterCode.SubOperationCode] }, }; var serverPeer = sPeer as ServerOutbouncePeer; var operation = new SitOperator(serverPeer.Protocol, message); if (!operation.IsValid) { serverPeer.SendMessage(new Response((byte)TexasOperationCode.Sit, null, errorParam, operation.GetErrorMessage(), (int)RoomErrorCode.OperationInvalid)); return(false); } var peerId = new Guid((Byte[])operation.PeerId); var roomID = operation.RoomID; errorParam.Add((byte)RoomParameterCode.RoomID, roomID); var facade = TexasApplication.GetRoom(roomID); if (facade == null) { serverPeer.SendMessage(new Response((byte)TexasOperationCode.Sit, null, errorParam, "RoomId Not Found", (int)RoomErrorCode.RoomIdNotFound)); return(false); } var userItem = TexasApplication.GetRoomUser(roomID, peerId); if (userItem == null) { serverPeer.SendMessage(new Response((byte)TexasOperationCode.Sit, null, errorParam, "User Not Yet Join Room", (int)RoomErrorCode.UserNotYetJoinRoom)); return(false); } var json = operation.TexasSitDown; TexasSitDown texasSitDown = JsonConvert.DeserializeObject <TexasSitDown>(json) as TexasSitDown; texasSitDown.sisDownInfo.UserKey = userItem.UserKey; texasSitDown.sisDownInfo.UserName = userItem.UserName; var texasRoomItem = TexasApplication.GetRoomItem(roomID); if (userItem.BankBalance < texasRoomItem.WithdrawMin && texasSitDown.sisDownInfo.IsSitDown) { serverPeer.SendMessage(new Response((byte)TexasOperationCode.Sit, null, errorParam, "Need $" + texasRoomItem.WithdrawMin + " to play", (int)RoomErrorCode.AmountTooLow)); return(false); } var stateMachine = facade.RetrieveMediator(TexasStateMachine.NAME) as TexasStateMachine; stateMachine.Sit(texasSitDown); return(true); }
public void PushSitDownNotification(TexasSitDown texasSitDown) { // var roomModel = this.Facade.RetrieveProxy(RoomModel.NAME) as RoomModel; var param = new Dictionary <byte, object>() { // { (byte)RoomParameterCode.RoomID, roomModel.RoomData.RoomID }, { (byte)ParameterCode.TexasSitDown, JsonConvert.SerializeObject(texasSitDown) }, }; var eevent = new Event((byte)TexasEventCode.SitDown, null, param); this.SendNotification(RoomNotification.SEND_EVENT_TO_ALL_USER, eevent); }
public override void Execute(INotification notification) { TexasSitDown texasSitDown = notification.Body as TexasSitDown; Log.DebugFormat("Execute:TexasSitCommand: " + texasSitDown.sisDownInfo.Index); var texasModel = this.Facade.RetrieveProxy(TexasModel.NAME) as TexasModel; if (texasSitDown.sisDownInfo.IsSitDown) { texasModel.sit(texasSitDown.sisDownInfo.UserKey, texasSitDown.sisDownInfo.Index, this); } else { texasModel.unsit(texasSitDown.sisDownInfo.UserKey, this); } }
private void sendSitDownInfoToAllUserInRoom(Slot player, int index, bool isSit, TexasSitDownListener listener) { if (listener == null) { return; } SitDownInfo sitDownInfo = new SitDownInfo(); sitDownInfo.AvatarKey = player.AvatarKey; sitDownInfo.Index = index; sitDownInfo.IsSitDown = isSit; sitDownInfo.UserKey = player.UserKey; sitDownInfo.UserName = player.UserName; TexasSitDown texasSitDown = new TexasSitDown(); texasSitDown.sisDownInfo = sitDownInfo; listener.PushSitDownNotification(texasSitDown); }
public void Sit(TexasSitDown assignee) { // Log.DebugFormat("TEXAS SIT FIRE"); this.States.Fire(_sitTrigger, assignee); }
private void OnSit(TexasSitDown texasSitDown) { Log.DebugFormat("TEXAS SIT CALLED: " + this.States.State); SendNotification(TexasTrigger.action_sit.ToString("G"), texasSitDown); }