本文整理汇总了C#中OperationResponse类的典型用法代码示例。如果您正苦于以下问题:C# OperationResponse类的具体用法?C# OperationResponse怎么用?C# OperationResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OperationResponse类属于命名空间,在下文中一共展示了OperationResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnHandleResponse
public override void OnHandleResponse(OperationResponse response)
{
NetworkManager view = _controller.ControlledView as NetworkManager;
if (response.ReturnCode == 0)
{
// TODO FIX THIS FOR ONLY 1 PLANET??
view.LogDebug(response.Parameters[(byte)ClientParameterCode.Planets].ToString());
DisplayManager.Instance.DisplayMessage("Planet Colonized!");
// Deserialize
var xmlData = response.Parameters[(byte)ClientParameterCode.Planets].ToString();
XmlSerializer deserializer = new XmlSerializer(typeof(XmlPlanetList));
TextReader reader = new StringReader(xmlData);
object obj = deserializer.Deserialize(reader);
XmlPlanetList planetCollection = (XmlPlanetList)obj;
reader.Close();
// Update local data
foreach (SanPlanet p in planetCollection.Planets)
PlayerData.instance.AddOwnedPlanet(new OwnedPlanet(p));
}
else
{
view.LogDebug("RESPONSE: " + response.DebugMessage);
DisplayManager.Instance.DisplayMessage(response.DebugMessage);
}
}
示例2: OnOperationRequest
protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
{
if (log.IsDebugEnabled)
{
log.DebugFormat("OnOperationRequest. Code={0}", operationRequest.OperationCode);
}
switch (operationRequest.OperationCode)
{
case (byte)MyOperationCodes.EchoOperation:
{
// The echo operation one is handled immediately because it does not require the client to join a game.
var myEchoRequest = new MyEchoRequest(this.Protocol, operationRequest);
if (this.ValidateOperation(myEchoRequest, sendParameters) == false)
{
return;
}
var myEchoResponse = new MyEchoResponse { Response = myEchoRequest.Text };
var operationResponse = new OperationResponse(operationRequest.OperationCode, myEchoResponse);
this.SendOperationResponse(operationResponse, sendParameters);
break;
}
default:
{
// for this example all other operations will handled by the base class
base.OnOperationRequest(operationRequest, sendParameters);
return;
}
}
}
示例3: OnOperationReturn
public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse)
{
Counters.ReceivedOperationResponse.Increment();
WindowsCounters.ReceivedOperationResponse.Increment();
switch (operationResponse.OperationCode)
{
case (byte)LoadBalancingEnums.OperationCode.Authenticate:
if (operationResponse.ReturnCode == 0)
{
client.AuthenticationTicket = (string)operationResponse[(byte)LoadBalancingEnums.ParameterCode.Secret];
this.TransitState(client);
}
else
{
log.WarnFormat("OnOperationReturn: Authenticate on Master failed: ReturnCode: {0} ({1}). Disconnecting...", operationResponse.ReturnCode, operationResponse.DebugMessage);
client.Peer.Disconnect();
}
break;
default:
{
log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode);
break;
}
}
}
示例4: OnHandlerMessage
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参数添加subCode
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.UpdataTaskDB(taskDB2);
response.ReturnCode = (short) ReturnCode.Success;
break;
}
}
示例5: OnHandlerMeesage
public override OperationResponse OnHandlerMeesage(OperationRequest request, ClientPeer peer)
{
//1.获得客户端发送的帐号和明文密码
object json;
request.Parameters.TryGetValue((byte) ParameterCode.UserCheckInfo, out json);
var user = JsonMapper.ToObject<User>(json.ToString());
var userDb = _manager.GetUserByUsername(user.Username);
var s = userDb != null
? string.Format("user.Username:{0},user.Password:{1} userDb.Username:{2},userDb.Password:{3}",
user.Username, user.Password, userDb.Username, userDb.Password)
: "未找到用户:" + user.Username;
peer.WriteLog(s);
//2.比较,然后创建响应
var response = new OperationResponse {OperationCode = request.OperationCode};
if (userDb != null && userDb.Password == MD5Tool.GetMD5(user.Password))
{
response.ReturnCode = (short) ReturnCode.Success;
peer.SetUser(userDb);
}
else
{
response.ReturnCode = (short) ReturnCode.Fail;
response.DebugMessage = "用户名或密码错误!";
}
return response;
}
示例6: OnOperationReturn
public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse)
{
Counters.ReceivedOperationResponse.Increment();
WindowsCounters.ReceivedOperationResponse.Increment();
switch (operationResponse.OperationCode)
{
case OperationCode.JoinGame:
{
if (operationResponse.ReturnCode == 0)
{
this.TransitState(client);
}
else
{
log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode);
client.Stop();
}
break;
}
default:
{
log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode);
break;
}
}
}
示例7: OnOperationRequest
protected override void OnOperationRequest(OperationRequest request, SendParameters sendParameters)
{
if (log.IsDebugEnabled)
{
log.DebugFormat("OnOperationRequest: pid={0}, op={1}", this.ConnectionId, request.OperationCode);
}
switch ((OperationCode)request.OperationCode)
{
default:
var response = new OperationResponse(request.OperationCode) { ReturnCode = (short)ErrorCode.OperationInvalid, DebugMessage = "Unknown operation code" };
this.SendOperationResponse(response, sendParameters);
break;
case OperationCode.Authenticate:
OperationResponse authenticateResponse = this.HandleAuthenticate(request);
this.SendOperationResponse(authenticateResponse, sendParameters);
break;
case OperationCode.CreateGame:
case OperationCode.JoinLobby:
case OperationCode.LeaveLobby:
case OperationCode.JoinRandomGame:
case OperationCode.JoinGame:
this.lobby.EnqueueOperation(this, request, sendParameters);
break;
}
}
示例8: DiscardItemResponseTask
private void DiscardItemResponseTask(OperationResponse operationResponse)
{
try
{
if (operationResponse.ReturnCode == (short)ErrorType.Correct)
{
ItemID itemID = (ItemID)operationResponse.Parameters[(byte)DiscardItemResponseItem.ItemID];
int itemCount = (int)operationResponse.Parameters[(byte)DiscardItemResponseItem.ItemCount];
if(OnDiscardItemResponse != null)
OnDiscardItemResponse(true, itemID, itemCount);
}
else
{
if (OnAlert != null)
OnAlert(operationResponse.DebugMessage);
if (OnDiscardItemResponse != null)
OnDiscardItemResponse(false, 0, 0);
}
}
catch (Exception ex)
{
DebugReturn(DebugLevel.ERROR, ex.Message);
DebugReturn(DebugLevel.ERROR, ex.StackTrace);
}
}
示例9: ExploreResponseTask
private void ExploreResponseTask(OperationResponse operationResponse)
{
try
{
if (operationResponse.ReturnCode == (short)ErrorType.Correct)
{
List<int> pathIDs = JsonConvert.DeserializeObject<List<int>>((string)operationResponse.Parameters[(byte)ExploreResponseItem.DiscoveredPathIDsDataString]);
List<Pathway> paths = new List<Pathway>();
foreach (int pathID in pathIDs)
{
if (GameGlobal.GlobalMap.paths.ContainsKey(pathID))
{
paths.Add(GameGlobal.GlobalMap.paths[pathID]);
}
}
if (OnExploreResponse != null)
OnExploreResponse(true, paths);
}
else
{
if (OnAlert != null)
OnAlert(operationResponse.DebugMessage);
if (OnExploreResponse != null)
OnExploreResponse(false, null);
}
}
catch (Exception ex)
{
DebugReturn(DebugLevel.ERROR, ex.Message);
DebugReturn(DebugLevel.ERROR, ex.StackTrace);
}
}
示例10: OnOperationResponse
public void OnOperationResponse(OperationResponse operationResponse)
{
// display operationCode
this.DebugReturn(0, string.Format("OperationResult:" +
operationResponse.OperationCode.ToString()));
switch (operationResponse.OperationCode)
{
case (byte)OperationCode.Login:
{
if (operationResponse.ReturnCode == (short)ErrorCode.Ok) // if success
{
getRet = Convert.ToInt32(operationResponse.Parameters[(byte)LoginResponseCode.Ret]);
getMemberID = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.MemberID]);
getMemberPW = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.MemberPW]);
getNickname = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.Nickname]);
LoginStatus = true;
}
else
{
LoginResult = operationResponse.DebugMessage;
LoginStatus = false;
}
break;
}
}
//throw new System.NotImplementedException();
}
示例11: OnOperationResponse
public override void OnOperationResponse (OperationResponse response)
{
SubCode subCode = ParameterTool.GetParameter<SubCode>(response.Parameters, ParameterCode.SubCode,false);
switch(subCode)
{
case SubCode.GetTaskDB:
List<TaskDB> list = ParameterTool.GetParameter< List<TaskDB> >(response.Parameters, ParameterCode.TaskDBList);
if(OnGetTaskDBList != null)
{
OnGetTaskDBList(list);
}
break;
case SubCode.AddTaskDB:
TaskDB taskDB = ParameterTool.GetParameter<TaskDB>(response.Parameters, ParameterCode.TaskDB);
if(OnAddTaskDB != null)
{
OnAddTaskDB(taskDB);
}
break;
case SubCode.UpdateTaskDB:
if(OnUpdateTaskDB != null)
{
OnUpdateTaskDB();
}
break;
}
}
示例12: OnHandlerMeesage
public override OperationResponse OnHandlerMeesage(OperationRequest request, ClientPeer peer)
{
object json;
request.Parameters.TryGetValue((byte) ParameterCode.UserCheckInfo, out json);
var user = JsonMapper.ToObject<User>(json.ToString());
var response = new OperationResponse {OperationCode = request.OperationCode};
//查询数据库
var userDb = _manager.GetUserByUsername(user.Username);
if (userDb == null)
{
if (_manager.RegisterUser(user))
{
response.ReturnCode = (short) ReturnCode.Success;
peer.SetUser(user);
}
else
{
response.ReturnCode = (short) ReturnCode.Eception;
response.DebugMessage = "异常";
}
}
else
{
response.ReturnCode = (short) ReturnCode.Fail;
response.DebugMessage = "用户名已存在!";
}
return response;
}
示例13: OnHandleResponse
public override void OnHandleResponse(OperationResponse response)
{
NetworkManager view = _controller.ControlledView as NetworkManager;
view.LogDebug("GOT A RESPONSE for KNOWN Planets");
if (response.ReturnCode == 0)
{
// TODO FIX THIS FOR ONLY 1 PLANET??
view.LogDebug(response.Parameters[(byte)ClientParameterCode.Planets].ToString());
// Deserialize
var xmlData = response.Parameters[(byte)ClientParameterCode.Planets].ToString();
XmlSerializer deserializer = new XmlSerializer(typeof(XmlPlanetList));
TextReader reader = new StringReader(xmlData);
object obj = deserializer.Deserialize(reader);
XmlPlanetList planetCollection = (XmlPlanetList)obj;
reader.Close();
// Update local data
foreach (SanPlanet p in planetCollection.Planets) {
var planet = PlayerData.instance.ownedPlanets.Find(x => x.starID == p.StarId && x.planetID == p.PlanetNum);
if (planet != null)
{
planet.planetpopulation = p.Population;
}
}
}
else
{
view.LogDebug("RESPONSE: " + response.DebugMessage);
DisplayManager.Instance.DisplayMessage(response.DebugMessage);
}
}
示例14: WorldEnterEventArgs
/// <summary>
/// 类型:方法
/// 名称:EnterWorldEventArgs
/// 作者:taixihuase
/// 作用:用自身角色进入场景所感兴趣的数据构造事件数据
/// 编写日期:2015/7/22
/// </summary>
/// <param name="response"></param>
public WorldEnterEventArgs(OperationResponse response)
{
Position position = (Position)
Serialization.Deserialize(response.Parameters[(byte) ParameterCode.WorldEnter]);
MyCharacterPosition = position;
AnyCharacter = null;
}
示例15: GetResponse
public virtual OperationResponse GetResponse(ErrorCode errorCode, string debugMessage = "")
{
var response = new OperationResponse(OperationRequest.OperationCode);
response.ReturnCode = (short) errorCode;
response.DebugMessage = debugMessage;
return response;
}