本文整理汇总了C#中SendParameters类的典型用法代码示例。如果您正苦于以下问题:C# SendParameters类的具体用法?C# SendParameters怎么用?C# SendParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SendParameters类属于命名空间,在下文中一共展示了SendParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnBroadcastMessage
public void OnBroadcastMessage(GamePeer peer, EventData eventData, SendParameters sendParameters)
{
if (peer != this)
{
this.SendEvent(eventData, sendParameters);
}
}
示例2: 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);
}
示例3: 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;
}
}
}
示例4: 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;
}
}
示例5: 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;
}
}
示例6: 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));
}
}
示例7: AuthenticateClient
public void AuthenticateClient(ICustomAuthPeer peer, IAuthenticateRequest authRequest, AuthSettings authSettings, SendParameters sendParameters, object state)
{
//TBD: why are we enqueuing could be done on the peers fiber
this.fiber.Enqueue(() =>
this.OnAuthenticateClient(peer, authRequest, authSettings, sendParameters, state)
);
}
示例8: 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;
}
}
示例9: 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));
}
}
示例10: BroadcastEvent
public void BroadcastEvent(IEventData evt, SendParameters param)
{
foreach (StarCollectorPeer peer in listPeer)
{
peer.SendEvent(evt, param);
}
}
示例11: 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;
}
}
}
示例12: 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);
}
示例13: 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);
}
示例14: HandleJoinGameWithLobby
/// <summary>
/// Joins the peer to a <see cref = "LiteLobbyGame" />.
/// Called by <see cref = "HandleJoinOperation">HandleJoinOperation</see>.
/// </summary>
/// <param name = "joinOperation">
/// The join operation.
/// </param>
/// <param name = "sendParameters">
/// The send Parameters.
/// </param>
protected virtual void HandleJoinGameWithLobby(JoinRequest joinOperation, SendParameters sendParameters)
{
// remove the peer from current game if the peer
// allready joined another game
this.RemovePeerFromCurrentRoom();
RoomReference gameReference = null;
if (joinOperation.ActorNr == 0)
{
// get a game reference from the game cache
// the game will be created by the cache if it does not exists allready
gameReference = LiteLobbyGameCache.Instance.GetRoomReference(joinOperation.GameId, this, joinOperation.LobbyId);
}
else
{
if (!LiteLobbyGameCache.Instance.TryGetRoomReference(joinOperation.GameId, this, out gameReference))
{
SendOperationResponse(
new OperationResponse
{
OperationCode = joinOperation.OperationRequest.OperationCode,
ReturnCode = -1,
DebugMessage = "the specified game is not exists."
},
sendParameters);
return;
}
}
// save the game reference in peers state
this.RoomReference = gameReference;
// enqueue the operation request into the games execution queue
gameReference.Room.EnqueueOperation(this, joinOperation.OperationRequest, sendParameters);
}
示例15: OnBroadcastMessage
private void OnBroadcastMessage(ChatPeer peer, EventData @event, SendParameters sendParameters)
{
if (peer != this)
{
this.SendEvent(@event, sendParameters);
}
}