예제 #1
0
        public override void OnHandlerMessage(Photon.SocketServer.OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            SubCode subCode = ParameterTool.GetParameter <SubCode>(request.Parameters, ParameterCode.SubCode, false);

            response.Parameters.Add((byte)ParameterCode.SubCode, subCode);
            switch (subCode)
            {
            case SubCode.AddTaskDB:
                TaskDB taskDB = ParameterTool.GetParameter <TaskDB>(request.Parameters, ParameterCode.TaskDB);
                taskDB.Role = peer.LoginRole;
                taskDBManager.AddTaskDB(taskDB);
                taskDB.Role = null;
                ParameterTool.AddParameter(response.Parameters, ParameterCode.TaskDB, taskDB);
                response.ReturnCode = (short)ReturnCode.Success;
                break;

            case SubCode.GetTaskDB:
                List <TaskDB> list = taskDBManager.GetTaskDBList(peer.LoginRole);
                foreach (var taskDb in list)
                {
                    taskDb.Role = null;
                }
                ParameterTool.AddParameter(response.Parameters, ParameterCode.TaskDBList, list);
                response.ReturnCode = (short)ReturnCode.Success;

                break;

            case SubCode.UpdateTaskDB:
                TaskDB taskDB2 = ParameterTool.GetParameter <TaskDB>(request.Parameters, ParameterCode.TaskDB);
                taskDB2.Role = peer.LoginRole;
                taskDBManager.UpdateTaskDB(taskDB2);
                response.ReturnCode = (short)ReturnCode.Success;
                break;
            }
        }
예제 #2
0
        public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer)
        {
            SubCode subCode = ParameterTool.GetParameter <SubCode>(request.Parameters, ParameterCode.SubCode, false);
            Dictionary <byte, object> parameters = response.Parameters;

            parameters.Add((byte)ParameterCode.SubCode, subCode);
            switch (subCode)
            {
            case SubCode.GetTaskDBList:
                List <TaskDB> taskDBList = manager.GetTaskDBList(peer.LoginRole);
                foreach (var taskDBTemp in taskDBList)
                {
                    taskDBTemp.Role = null;      //防止json解析错误
                }
                ParameterTool.AddParameter(response.Parameters, ParameterCode.TaskDBList, taskDBList);
                response.ReturnCode = (short)ReturnCode.Success;
                break;

            case SubCode.AddTaskDB:
                TaskDB taskDBAdd = ParameterTool.GetParameter <TaskDB>(request.Parameters, ParameterCode.TaskDB);
                taskDBAdd.Role = peer.LoginRole;
                manager.AddTaskDB(taskDBAdd);
                taskDBAdd.Role = null;
                ParameterTool.AddParameter(response.Parameters, ParameterCode.TaskDB, taskDBAdd);
                response.ReturnCode = (short)ReturnCode.Success;
                break;

            case SubCode.UpdateTaskDB:
                TaskDB taskDBUpdate = ParameterTool.GetParameter <TaskDB>(request.Parameters, ParameterCode.TaskDB);
                taskDBUpdate.Role = peer.LoginRole;
                manager.UpdateTaskDB(taskDBUpdate);
                response.ReturnCode = (short)ReturnCode.Success;
                break;
            }
        }