1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Collections.Generic;
- using static System.Collections.Specialized.BitVector32;
- namespace ET.Client
- {
- public class RequestServerUtil : Singleton<RequestServerUtil>
- {
- public async ETTask OpenRequestServer(ushort messageId,Dictionary<string,object> param = null, Action<object, int> cb = null )
- {
- Scene scene = GameUtil.Instance.GetSceneComponent();
- Session session = scene.GetComponent<SessionComponent>().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 HGHHMessage.C2G_HGHHOperation:
- {
- var OpType = param["OpType"];
- var Card = param["Card"];
- G2C_HGHHOperation g2Operation = (G2C_HGHHOperation)await session.Call(
- new C2G_HGHHOperation() { 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;
- }
- }
- }
- }
- }
|