Exemple #1
0
    public override void Execute(INotification notification)
    {
        int     mainproto = int.Parse(notification.Name);
        CmdType type      = (CmdType)Enum.Parse(typeof(CmdType), notification.Type);

        if (type == CmdType.Request)
        {
            Message message = notification.Body as Message;
            Notify  notify  = new Notify();
            notify.Protocol = mainproto;
            switch (mainproto)
            {
            case Protocol.Login:
                LoginReq loginReq = ReferencePool.Require <LoginReq>();
                loginReq.Account  = message.args[0].ToString();
                loginReq.Password = message.args[1].ToString();
                notify.message    = loginReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.Regist:
                RegisterReq registerReq = ReferencePool.Require <RegisterReq>();
                registerReq.Account  = message.args[0].ToString();
                registerReq.Password = message.args[1].ToString();
                notify.message       = registerReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;
            }
        }
    }
    public override void Execute(INotification notification)
    {
        int     mainproto = int.Parse(notification.Name);
        CmdType type      = (CmdType)int.Parse(notification.Type);
        Message message   = notification.Body as Message;
        Notify  notify    = new Notify();

        notify.Protocol = mainproto;
        if (type == CmdType.Request)
        {
            switch (mainproto)
            {
            case Protocol.UserMessage_Update:
                UserMessage_UpdateReq userUpdate = ReferencePool.Require <UserMessage_UpdateReq>();
                userUpdate.Uid            = int.Parse(message.args[0]);
                userUpdate.UserName       = message.args[1].ToString();
                userUpdate.UserAge        = int.Parse(message.args[2]);
                userUpdate.UserProfession = message.args[3].ToString();
                userUpdate.UserScore      = int.Parse(message.args[4]);
                notify.message            = userUpdate.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;
            }
        }
    }
    public override void Execute(INotification notification)
    {
        int     mainproto = int.Parse(notification.Name);
        CmdType type      = (CmdType)Enum.Parse(typeof(CmdType), notification.Type);

        if (type == CmdType.Request)
        {
            Message message = notification.Body as Message;
            Notify  notify  = new Notify();
            notify.Protocol = mainproto;
            switch (mainproto)
            {
            case Protocol.Project_Add:
                Project_AddReq addReq = ReferencePool.Require <Project_AddReq>();
                addReq.ProjectName = message.args[0];
                addReq.Priority    = int.Parse(message.args[1]);
                addReq.Description = message.args[2];
                addReq.CreateDate  = message.args[3];
                addReq.LimitDate   = message.args[4];
                notify.message     = addReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;
            }
        }
    }
Exemple #4
0
    //数据解包
    public static void UnPackData(byte[] notifybyte)
    {
        Notify notify = ReferencePool.Require <Notify>();

        notify.Protocol = BitConverter.ToInt32(notifybyte, 0);
        notify.Feedback = BitConverter.ToInt32(notifybyte, 4);
        notify.message  = notifybyte.Skip(8).ToArray();
        HandleResponse(notify);
    }
Exemple #5
0
    /// <summary>
    /// 注册命令到controller层
    /// </summary>
    /// <param name="notifiname">命令名字</param>
    public static void RegisterCommand <T>(params int[] notifiname) where T : class, ICommand, new()
    {
        IController controller = Controller.GetInstance(delegate { return(new Controller()); });

        for (int i = 0; i < notifiname.Length; i++)
        {
            controller.RegisterCommand(notifiname[i].ToString(), delegate { return(ReferencePool.Require <T>() as ICommand); });
        }
    }
    public static IUI FindUI <T>() where T : class, IUI, new()
    {
        IUI uI = mUICache.Find((match) => { return(match is T); });

        if (uI == null)
        {
            uI = ReferencePool.Require <T>() as IUI;
            mUICache.Add(uI);
        }
        return(uI);
    }
    public static void Execute(int proto, params object[] msg)
    {
        Message mes = ReferencePool.Require <Message>();

        mes.args = new List <string>();
        Debug.Log("-><color=#00EEEE>" + "发送消息 :" + proto + "</color>");
        for (int i = 0; i < msg.Length; i++)
        {
            mes.args.Add(msg[i].ToString());
            Debug.Log(msg[i].ToString());
        }

        GameFacade.SendNotification(proto, CmdType.Request, mes);
    }
    public override void Execute(INotification notification)
    {
        int     mainproto = int.Parse(notification.Name);
        CmdType type      = (CmdType)Enum.Parse(typeof(CmdType), notification.Type);

        if (type == CmdType.Request)
        {
            Message message = notification.Body as Message;
            Notify  notify  = new Notify();
            notify.Protocol = mainproto;
            switch (mainproto)
            {
            case Protocol.Friend_Check:
                Friend_CheckReq Req = ReferencePool.Require <Friend_CheckReq>();
                Req.Uid        = int.Parse(message.args[0]);
                notify.message = Req.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;
            }
        }
    }
    public override void Execute(INotification notification)
    {
        int     mainproto = int.Parse(notification.Name);
        CmdType type      = (CmdType)int.Parse(notification.Type);
        Message message   = notification.Body as Message;
        Notify  notify    = new Notify();

        notify.Protocol = mainproto;
        if (type == CmdType.Request)
        {
            switch (mainproto)
            {
            case Protocol.Project_Check:
                Project_CheckReq checkReq = ReferencePool.Require <Project_CheckReq>();
                checkReq.Empty = 0;
                notify.message = checkReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.Project_Add:
                Project_AddReq addReq = ReferencePool.Require <Project_AddReq>();
                addReq.ProjectName = message.args[0].ToString();
                addReq.Priority    = int.Parse(message.args[1]);
                addReq.Description = message.args[2].ToString();
                addReq.CreateDate  = message.args[3].ToString();
                addReq.LimitDate   = message.args[4].ToString();
                notify.message     = addReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.Project_Delete:
                Project_DeleteReq deleteReq = ReferencePool.Require <Project_DeleteReq>();
                deleteReq.ProjectID = int.Parse(message.args[0]);
                notify.message      = deleteReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;
            }
        }
    }
Exemple #10
0
    public override void Execute(INotification notification)
    {
        int     mainproto = int.Parse(notification.Name);
        CmdType type      = (CmdType)int.Parse(notification.Type);
        Message message   = notification.Body as Message;
        Notify  notify    = new Notify();

        notify.Protocol = mainproto;
        if (type == CmdType.Request)
        {
            switch (mainproto)
            {
            case Protocol.Friend_Check:
                Friend_CheckReq checkReq = ReferencePool.Require <Friend_CheckReq>();
                checkReq.Uid   = int.Parse(message.args[0]);
                notify.message = checkReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.Friend_Add:
                Friend_AddReq addReq = ReferencePool.Require <Friend_AddReq>();
                addReq.ThisUid = int.Parse(message.args[0]);
                addReq.ThatUid = int.Parse(message.args[1]);
                notify.message = addReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.Friend_Delete:
                Friend_DeleteReq deleteReq = ReferencePool.Require <Friend_DeleteReq>();
                deleteReq.ThisUid = int.Parse(message.args[0]);
                deleteReq.ThatUid = int.Parse(message.args[1]);
                notify.message    = deleteReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.UserMessage_Look:
                UserMessage_LookReq lookreq = ReferencePool.Require <UserMessage_LookReq>();
                lookreq.Uid    = int.Parse(message.args[0]);
                notify.message = lookreq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.FriendApply_Check:
                FriendApply_CheckReq applycheckReq = ReferencePool.Require <FriendApply_CheckReq>();
                applycheckReq.Uid = int.Parse(message.args[0]);
                notify.message    = applycheckReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.FriendApply_Agree:
                FriendApply_AgreeReq agreeReq = ReferencePool.Require <FriendApply_AgreeReq>();
                agreeReq.ThisUid = int.Parse(message.args[0]);
                agreeReq.ThatUid = int.Parse(message.args[1]);
                notify.message   = agreeReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.FriendApply_Disagree:
                FriendApply_DisagreeReq disaReq = ReferencePool.Require <FriendApply_DisagreeReq>();
                disaReq.ThisUid = int.Parse(message.args[0]);
                disaReq.ThatUid = int.Parse(message.args[1]);
                notify.message  = disaReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.BlackList_Check:
                BlackList_CheckReq blackcheck = ReferencePool.Require <BlackList_CheckReq>();
                blackcheck.Uid = int.Parse(message.args[0]);
                notify.message = blackcheck.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.BlackList_Add:
                BlackList_AddReq blackaddReq = ReferencePool.Require <BlackList_AddReq>();
                blackaddReq.ThisUid = int.Parse(message.args[0]);
                blackaddReq.ThatUid = int.Parse(message.args[1]);
                notify.message      = blackaddReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;

            case Protocol.BlackList_Delete:
                BlackList_DeleteReq blackdeleteReq = ReferencePool.Require <BlackList_DeleteReq>();
                blackdeleteReq.ThisUid = int.Parse(message.args[0]);
                blackdeleteReq.ThatUid = int.Parse(message.args[1]);
                notify.message         = blackdeleteReq.ToByteArray();
                NetworkManager.SendRequest(notify);
                break;
            }
        }
    }
Exemple #11
0
 /// <summary>
 /// 注册自定义代理
 /// </summary>
 /// <param name="proxy"></param>
 public static void RegisterProxy <T>() where T : class, IProxy, new()
 {
     PureMVC.IModel model = Model.GetInstance(delegate { return(new Model()); });
     model.RegisterProxy(ReferencePool.Require <T>() as IProxy);
 }
Exemple #12
0
 /// <summary>
 /// 注册中介者
 /// </summary>
 /// <param name="mediator"></param>
 public static void RegisterMediator <T>() where T : class, IMediator, new()
 {
     PureMVC.IView view = View.GetInstance(delegate { return(new View()); });
     view.RegisterMediator(ReferencePool.Require <T>() as IMediator);
 }