本文整理汇总了C#中OperationRequest类的典型用法代码示例。如果您正苦于以下问题:C# OperationRequest类的具体用法?C# OperationRequest怎么用?C# OperationRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OperationRequest类属于命名空间,在下文中一共展示了OperationRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: JoinGameWithLobby
public void JoinGameWithLobby()
{
string roomName = CreateRandomRoomName();
TestClient client = this.InitClient();
var request = new OperationRequest { OperationCode = (byte)OperationCode.Join, Parameters = new Dictionary<byte, object>() };
request.Parameters.Add((byte)ParameterKey.GameId, roomName);
request.Parameters.Add((byte)LobbyParameterKeys.LobbyId, "Mainlobby");
client.SendOperationRequest(request);
OperationResponse response = client.WaitForOperationResponse(this.WaitTime);
EventData eventArgs = client.WaitForEvent(this.WaitTime);
// check operation params
CheckDefaultOperationParameters(response, OperationCode.Join);
CheckParam(response, ParameterKey.ActorNr, 1);
// check event params
CheckDefaultEventParameters(eventArgs, OperationCode.Join, 1);
CheckEventParamExists(eventArgs, ParameterKey.Actors);
// cleanup
client.Close();
client.Dispose();
}
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:25,代码来源:LobbyTests.cs
示例2: 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;
}
}
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:28,代码来源:MasterClientPeer.cs
示例3: InvalidOperation
/// <summary>
/// Handles all operations that are not allowed before operation <see cref = "EnterWorld" /> is called.
/// </summary>
/// <param name = "request">
/// The request.
/// </param>
/// <returns>
/// An <see cref = "OperationResponse" /> with <see cref = "ReturnCode.InvalidOperation" />.
/// </returns>
public static OperationResponse InvalidOperation(OperationRequest request)
{
return new OperationResponse(request.OperationCode)
{
ReturnCode = (int)ReturnCode.InvalidOperation, DebugMessage = "InvalidOperation: " + (OperationCode)request.OperationCode
};
}
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:16,代码来源:MmoPeer.cs
示例4: JoinGameWithLobby
public void JoinGameWithLobby()
{
string roomName = CreateRandomRoomName();
TestClient client = this.InitClient();
OperationRequest request = new OperationRequest((short)OperationCodes.Join);
request.Params.Add((short)ParameterKeys.GameId, roomName);
request.Params.Add((short)LiteLobby.Operations.LobbyParameterKeys.LobbyId, "Mainlobby");
client.SendOperationRequest(request, 0, true);
OperationResponse response = client.WaitForOperationResponse(this.WaitTime);
EventReceivedEventArgs eventArgs = client.WaitForEvent(this.WaitTime);
// check operation params
CheckDefaultOperationParams(response, OperationCodes.Join);
CheckParam(response, ParameterKeys.ActorNr, 1);
// check event params
CheckDefaultEventParams(eventArgs, OperationCodes.Join, 1);
CheckEventParamExists(eventArgs, ParameterKeys.Actors);
// cleanup
client.Close();
client.Dispose();
}
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:25,代码来源:LobbyTests.cs
示例5: TryRegist
/// <summary>
/// 类型:方法
/// 名称:TryRegist
/// 作者:taixihuase
/// 作用:通过请求的角色数据,尝试创建、记录一个新的角色数据并再次返回给客户端
/// 编写日期:2015/7/14
/// </summary>
/// <param name="operationRequest"></param>
/// <param name="sendParameters"></param>
/// <param name="peer"></param>
private static void TryRegist(OperationRequest operationRequest, SendParameters sendParameters, ServerPeer peer)
{
ServerPeer.Log.Debug("Regist a new account...");
RegistInfo info = (RegistInfo)
Serialization.Deserialize(operationRequest.Parameters[(byte) ParameterCode.Regist]);
UserCollection.UserReturn userReturn = peer.Server.Users.RegistUser(info);
if (userReturn.ReturnCode == UserCollection.UserReturn.ReturnCodeType.Success)
{
OperationResponse response = new OperationResponse((byte)OperationCode.Regist)
{
ReturnCode = (short)ErrorCode.Ok,
DebugMessage = "账号创建成功!"
};
peer.SendOperationResponse(response, sendParameters);
}
else
{
OperationResponse response = new OperationResponse((byte)OperationCode.Regist)
{
ReturnCode = (short)ErrorCode.InvalidOperation,
DebugMessage = userReturn.DebugMessage.ToString()
};
peer.SendOperationResponse(response, sendParameters);
ServerPeer.Log.Debug(DateTime.Now + " : Failed to regist " + info.Account + " Because of " +
Enum.GetName(typeof(UserCollection.UserReturn.ReturnCodeType),
userReturn.ReturnCode));
}
}
开发者ID:taixihuase,项目名称:SiegeOnline,代码行数:42,代码来源:Regist.cs
示例6: OnOperationRequest
protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
{
switch (operationRequest.OperationCode)
{
default:
{
string message = string.Format("Unknown operation code {0}", operationRequest.OperationCode);
this.SendOperationResponse(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = message }, sendParameters);
break;
}
case 1:
{
var pingOperation = new LatencyOperation(this.Protocol, operationRequest.Parameters);
if (pingOperation.IsValid == false)
{
this.SendOperationResponse(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = pingOperation.GetErrorMessage() }, sendParameters);
return;
}
Thread.Sleep(5);
var response = new OperationResponse(operationRequest.OperationCode, pingOperation);
this.SendOperationResponse(response, sendParameters);
break;
}
}
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:28,代码来源:LatencyPeer.cs
示例7: OnHandleRequest
public override void OnHandleRequest(OperationRequest request)
{
Log.Debug("SubServerLogin Handler sending response of 1");
var para = new Dictionary<byte, object>
{{(byte) ParameterCode.UserId, request.Parameters[(byte) ParameterCode.UserId]}};
_peer.SendOperationResponse(new OperationResponse(1) {Parameters = para}, new SendParameters {ChannelId = 0, Unreliable = false});
}
开发者ID:Antaresgames,项目名称:AegisBornPhoton,代码行数:7,代码来源:SubServerLoginHandler.cs
示例8: SetPropertiesRequest
/// <summary>
/// Initializes a new instance of the <see cref="SetPropertiesRequest"/> class.
/// </summary>
/// <param name="protocol">
/// The protocol.
/// </param>
/// <param name="operationRequest">
/// Operation request containing the operation parameters.
/// </param>
public SetPropertiesRequest(IRpcProtocol protocol, OperationRequest operationRequest)
: base(protocol, operationRequest)
{
if (!this.IsValid)
{
return;
}
// special handling for game and actor properties send by AS3/Flash (Amf3 protocol) or JSON clients
if (protocol.ProtocolType == ProtocolType.Amf3V16 || protocol.ProtocolType == ProtocolType.Json)
{
if (this.UpdatingGameProperties)
{
Utilities.ConvertAs3WellKnownPropertyKeys(this.Properties, null);
Utilities.ConvertAs3WellKnownPropertyKeys(this.ExpectedValues, null);
}
else
{
Utilities.ConvertAs3WellKnownPropertyKeys(null, this.Properties);
Utilities.ConvertAs3WellKnownPropertyKeys(null, this.ExpectedValues);
}
}
if (this.UpdatingGameProperties)
{
this.isValid = GameParameterReader.TryGetProperties(this.Properties, out this.newMaxPlayer,
out this.newIsOpen, out this.newIsVisible,
out this.newLobbyProperties, out this.MasterClientId,
out this.ExpectedUsers, out this.errorMessage);
}
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:40,代码来源:SetPropertiesRequest.cs
示例9: EntitySearchWidgetViewModel
public EntitySearchWidgetViewModel(Widget model, IApplicationState applicationState, ICacheService cacheService, IEntityService entityService)
: base(model, applicationState)
{
_applicationState = applicationState;
_cacheService = cacheService;
EntitySearchViewModel = new EntitySearchViewModel(applicationState, cacheService, entityService) { IsKeyboardVisible = false };
EventServiceFactory.EventService.GetEvent<GenericEvent<OperationRequest<Entity>>>().Subscribe(x =>
{
if (x.Topic == EventTopicNames.SelectEntity)
{
_request = x.Value;
}
});
EventServiceFactory.EventService.GetEvent<GenericEvent<WidgetEventData>>().Subscribe(
x =>
{
if (x.Value.WidgetName == Name)
{
EntitySearchViewModel.SearchString = x.Value.Value;
}
});
}
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:25,代码来源:EntitySearchWidgetViewModel.cs
示例10: OnOperationRequest
protected override void OnOperationRequest(OperationRequest request, SendParameters sendParameters)
{
switch (request.OperationCode)
{
case (byte)OperationCode.Authenticate:
this.HandleAuthenticateOperation(request, sendParameters);
return;
case (byte)OperationCode.CreateGame:
this.HandleCreateGameOperation(request, sendParameters);
return;
case (byte)OperationCode.JoinGame:
this.HandleJoinGameOperation(request, sendParameters);
return;
case (byte)Lite.Operations.OperationCode.Leave:
this.HandleLeaveOperation(request, sendParameters);
return;
case (byte)Lite.Operations.OperationCode.Ping:
this.HandlePingOperation(request, sendParameters);
return;
case (byte)OperationCode.DebugGame:
this.HandleDebugGameOperation(request, sendParameters);
return;
case (byte)SPOperationCode.UpdateFlightControls:
this.HandleGameOperation(request, sendParameters);
return;
}
base.OnOperationRequest(request, sendParameters);
}
开发者ID:coryleeio,项目名称:SPServer,代码行数:35,代码来源:GameClientPeer.cs
示例11: 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;
}
}
}
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:32,代码来源:MyPeer.cs
示例12: 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;
}
开发者ID:XmingBunny,项目名称:ARPGPhotonServer,代码行数:28,代码来源:LoginHandler.cs
示例13: UpdateEntityScreens
private EntityScreen UpdateEntityScreens(OperationRequest<Entity> value)
{
var entityScreens =
_applicationState.IsLocked ?
_applicationState.GetTicketEntityScreens().ToList() :
_applicationState.GetEntityScreens().ToList();
if (!entityScreens.Any()) return null;
_entityScreens = entityScreens.OrderBy(x => x.SortOrder).ToList();
_entitySwitcherButtons = null;
var selectedScreen = _applicationState.SelectedEntityScreen;
if (value != null && value.SelectedItem != null && _applicationState.CurrentDepartment != null)
{
if (_applicationState.IsLocked || _applicationState.CurrentDepartment.TicketCreationMethod == 1)
_entityScreens = _entityScreens.Where(x => x.EntityTypeId == value.SelectedItem.EntityTypeId).OrderBy(x => x.SortOrder);
if (!_entityScreens.Any())
return entityScreens.ElementAt(0);
if (selectedScreen == null || selectedScreen.EntityTypeId != value.SelectedItem.EntityTypeId)
{
selectedScreen = null;
if (!string.IsNullOrEmpty(value.Data))
{
selectedScreen = _entityScreens.Where(x => x.DisplayMode == 1).FirstOrDefault(x => x.EntityTypeId == value.SelectedItem.EntityTypeId);
}
if (selectedScreen == null)
{
selectedScreen = _entityScreens.FirstOrDefault(x => x.EntityTypeId == value.SelectedItem.EntityTypeId);
}
}
if (selectedScreen == null) selectedScreen = _entityScreens.ElementAt(0);
}
return selectedScreen ?? EntityScreens.ElementAt(0);
}
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:32,代码来源:EntitySwitcherViewModel.cs
示例14: TryEnter
/// <summary>
/// 类型:方法
/// 名称:TryEnter
/// 作者:taixihuase
/// 作用:通过角色数据尝试进入场景
/// 编写日期:2015/7/22
/// </summary>
/// <param name="operationRequest"></param>
/// <param name="sendParameters"></param>
/// <param name="peer"></param>
private static void TryEnter(OperationRequest operationRequest, SendParameters sendParameters, ServerPeer peer)
{
ServerPeer.Log.Debug("Entering");
int uniqueId = (int)
Serialization.Deserialize(operationRequest.Parameters[(byte) ParameterCode.WorldEnter]);
Character character;
if (peer.Server.Characters.CharacterEnter(uniqueId, out character))
{
peer.Server.Data.CharacterData.GetCharacterPosition(character);
}
// 返回数据给客户端
byte[] pos = Serialization.Serialize(character.Position);
OperationResponse reponseData = new OperationResponse((byte) OperationCode.WorldEnter,
new Dictionary<byte, object>
{
{(byte) ParameterCode.WorldEnter, pos}
})
{
ReturnCode = (short) ErrorCode.Ok,
DebugMessage = "进入场景成功"
};
peer.SendOperationResponse(reponseData, sendParameters);
byte[] data = Serialization.Serialize(character);
EventData eventData = new EventData((byte) EventCode.WorldEnter, new Dictionary<byte, object>
{
{(byte) ParameterCode.WorldEnter, data}
});
eventData.SendTo(peer.Server.Characters.GamingClientsToBroadcast, sendParameters);
}
开发者ID:taixihuase,项目名称:SiegeOnline,代码行数:45,代码来源:WorldEnter.cs
示例15: OnOperationRequest
protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
{
var operationCode = (OperationCode) operationRequest.OperationCode;
if (_context == null)
{
if (operationCode != OperationCode.SetupContext)
throw new ArgumentException($"Failed to process operation request '{operationCode}', the context has not been initialized");
var contextType = (ContextType) operationRequest.Parameters[(byte) OperationParameterCode.ContextType];
if (contextType == ContextType.InstanceServer)
_context = new InstanceClientContext(_application, this);
else if (contextType == ContextType.RegionServer)
_context = new RegionClientContext(_application, this);
else if (contextType == ContextType.PlayerClient)
_context = new PlayerClientContext(_application, this);
else if (contextType == ContextType.ConsoleClient)
_context = new ConsoleClientContext(_application, this);
else
throw new ArgumentException($"Failed setup context type '{contextType}', the context type was not recognized");
return;
}
_context.OnOperationRequest(operationCode, operationRequest.Parameters);
}
开发者ID:rioter00,项目名称:Project-Ethos,代码行数:27,代码来源:Peer.cs
示例16: OnOperationRequest
protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
{
WriteLog("Receive RequestCode:" + (OperationCode) operationRequest.OperationCode);
HandlerBase handler;
ArpgApplication.Instance.Handlers.TryGetValue(operationRequest.OperationCode, out handler);
if (handler != null)
{
//1.处理
var response = handler.OnHandlerMeesage(operationRequest, this);
//2.发送响应
SendOperationResponse(response, sendParameters);
//3.日志记录
object subCode = null;
WriteLog(string.Format("Rsponse operationCode:{0} success",
(OperationCode) operationRequest.OperationCode));
}
else
{
//1.异常,日志记录
WriteLog(string.Format("Can not find OperationCode:{0}",
(OperationCode) operationRequest.OperationCode));
}
}
开发者ID:XmingBunny,项目名称:ARPGPhotonServer,代码行数:26,代码来源:ClientPeer.cs
示例17: HandleOperationRequest
public virtual void HandleOperationRequest(GamePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
{
switch (operationRequest.OperationCode)
{
case CommonOperationCode.Join:
HandleJoinOperation(peer, operationRequest, sendParameters);
break;
case CommonOperationCode.Exit:
HandleExitOperation(peer, operationRequest, sendParameters);
break;
case CommonOperationCode.Chat:
HandleChatOperation(peer, operationRequest, sendParameters);
break;
case CommonOperationCode.GetRooms:
SendAllRoomStatus(peer, sendParameters);
break;
case CommonOperationCode.ConfirmJoin:
var task = HandleConfirmJoinOperation(peer, operationRequest, sendParameters);
task.Wait();
break;
}
}
开发者ID:rkdrnf,项目名称:photonserver,代码行数:26,代码来源:GameCore.cs
示例18: HandleConfirmJoinOperation
public async Task HandleConfirmJoinOperation(GamePeer peer, OperationRequest operationRequest, SendParameters sendParameters)
{
var joinRequest = new ConfirmJoinRequest(peer.Protocol, operationRequest);
if (!peer.ValidateOperation(joinRequest, sendParameters))
{
return;
}
//string playerInfoStr = await WebHelper.RequestPlayerInfo(joinRequest.UserKey);
string playerInfoStr = "{ \"username\": \"test\", \"game_money\": 2000 }";
PlayerInfo info = JsonConvert.DeserializeObject<PlayerInfo>(playerInfoStr);
PeerManager.Instance.OnPeerJoin(peer, new PeerInfo(peer, joinRequest.RoomID, joinRequest.UserKey));
var room = FindRoom(joinRequest.RoomID);
if (room != null)
{
room.ExecutionFiber.Enqueue(() => room.Join(peer, joinRequest, sendParameters, info));
}
else
{
var response = new OperationResponse(CommonOperationCode.ConfirmJoin,
new Dictionary<byte, object> { { (byte)CommonParameterKey.Success, false } });
peer.SendOperationResponse(response, sendParameters);
}
}
开发者ID:rkdrnf,项目名称:photonserver,代码行数:28,代码来源:GameCore.cs
示例19: 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;
}
开发者ID:XmingBunny,项目名称:ARPGPhotonServer,代码行数:29,代码来源:RegisterHandler.cs
示例20: CreateWorld
public static OperationRequest CreateWorld(string worldName, BoundingBox boundingBox, Vector tileDimensions)
{
var request = new OperationRequest { OperationCode = (byte)OperationCode.CreateWorld, Parameters = new Dictionary<byte, object>() };
request.Parameters.Add((byte)ParameterCode.WorldName, worldName);
request.Parameters.Add((byte)ParameterCode.BoundingBox, boundingBox);
request.Parameters.Add((byte)ParameterCode.TileDimensions, tileDimensions);
return request;
}
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:8,代码来源:Operations.cs
注:本文中的OperationRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论