using System; using System.Collections.Generic; using static System.Collections.Specialized.BitVector32; namespace ET.Client { public class RequestServerUtil : Singleton { public async ETTask OpenRequestServer(ushort messageId,Dictionary param = null, Action cb = null ) { Scene scene = GameUtil.Instance.GetSceneComponent(); Session session = scene.GetComponent().Session; switch (messageId) { case OuterMessage.C2G_CreatRoom: { G2C_CreatRoom g2CreatRoom = (G2C_CreatRoom)await session.Call( new C2G_CreatRoom() { }); if (g2CreatRoom.Error != ErrorCode.ERR_Success) { cb?.Invoke(null, g2CreatRoom.Error); return; } cb?.Invoke(g2CreatRoom.Info, ErrorCode.ERR_Success); break; } case OuterMessage.C2G_JoinRoom: { var roomId = param["roomId"]; G2C_JoinRoom g2JoinRoom = (G2C_JoinRoom)await session.Call( new C2G_JoinRoom() { RoomId = int.Parse(roomId.ToString()) }); if (g2JoinRoom.Error != ErrorCode.ERR_Success) { cb?.Invoke(null, g2JoinRoom.Error); return; } cb?.Invoke(null, ErrorCode.ERR_Success); break; } case OuterMessage.C2G_Operation: { var OpType = param["OpType"]; var Card = param["Card"]; G2C_Operation g2Operation = (G2C_Operation)await session.Call( new C2G_Operation() { OpType = int.Parse(OpType.ToString()), Card = int.Parse(Card.ToString()) }); if (g2Operation.Error != ErrorCode.ERR_Success) { cb?.Invoke(null, g2Operation.Error); return; } cb?.Invoke(null, ErrorCode.ERR_Success); break; } } } } }