本文整理汇总了C#中PeerBase类的典型用法代码示例。如果您正苦于以下问题:C# PeerBase类的具体用法?C# PeerBase怎么用?C# PeerBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PeerBase类属于命名空间,在下文中一共展示了PeerBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RoomReference
/// <summary>
/// Initializes a new instance of the <see cref="RoomReference"/> class.
/// </summary>
/// <param name="roomCache">
/// The room cache.
/// </param>
/// <param name="room">
/// The room.
/// </param>
public RoomReference(RoomCacheBase roomCache, Room room, PeerBase ownerPeer)
{
this.roomCache = roomCache;
this.id = Guid.NewGuid();
this.Room = room;
this.ownerPeer = ownerPeer;
}
示例2: Actor
/// <summary>
/// Initializes a new instance of the <see cref = "Actor" /> class.
/// </summary>
/// <param name = "peer">
/// The owner peer.
/// </param>
/// <param name = "world">
/// The world.
/// </param>
protected Actor(PeerBase peer, IWorld world)
{
this.peer = peer;
this.world = world;
this.ownedItems = new Dictionary<byte, Dictionary<string, Item>>();
this.interestAreas = new Dictionary<byte, InterestArea>();
}
示例3: MmoActor
protected MmoActor(PeerBase peer, World world)
{
this.peer = peer;
this.world = world;
this.interestAreas = new Dictionary<byte, InterestArea>();
this.interestItems = new InterestItems(peer);
}
示例4: AddSubscription
public Subscription AddSubscription(PeerBase peer, int gameCount)
{
if (log.IsDebugEnabled)
{
log.DebugFormat("New Subscription: pid={0}, gc={1}, props={2}", peer.ConnectionId, gameCount, this.propertyString);
}
if (gameCount < 0)
{
gameCount = 0;
}
var subscription = new Subscription(this, peer, gameCount);
HashSet<PeerBase> hashSet;
if (this.subscriptions.TryGetValue(gameCount, out hashSet) == false)
{
if (log.IsDebugEnabled)
{
log.DebugFormat("Creating new hashset for game count = {0}", gameCount);
}
hashSet = new HashSet<PeerBase>();
this.subscriptions.Add(gameCount, hashSet);
}
hashSet.Add(peer);
return subscription;
}
示例5: PeerDisconnected
public void PeerDisconnected(PeerBase peer)
{
lock (Connections)
{
Connections.Remove(peer);
}
}
示例6: PeerConnected
public void PeerConnected(PeerBase peer)
{
lock(Connections)
{
Connections.Add(peer);
}
}
示例7: ClientInterestArea
/// <summary>
/// Initializes a new instance of the <see cref = "ClientInterestArea" /> class.
/// </summary>
/// <param name = "peer">
/// The peer.
/// </param>
/// <param name = "id">
/// The id for this interest area.
/// Unique per <see cref = "Actor" />.
/// </param>
/// <param name = "world">
/// The <see cref = "IWorld" /> this interest area is watching.
/// </param>
/// <param name = "fiber">
/// The fiber this intereast receives events on.
/// </param>
public ClientInterestArea(PeerBase peer, byte id, IWorld world, IFiber fiber)
: base(id, world)
{
this.peer = peer;
this.eventChannelSubscriptions = new Dictionary<Item, IDisposable>();
this.fiber = fiber;
}
示例8: OnDisconnectByOtherPeer
/// <summary>
/// Kicks the actor from the world (event WorldExited is sent to the client) and then disconnects the client.
/// </summary>
/// <remarks>
/// Called by DisconnectByOtherPeer after being enqueued to the PeerBase.RequestFiber.
/// It kicks the actor from the world (event WorldExited) and then continues the original request by calling the original peer's OnOperationRequest method.
/// </remarks>
public void OnDisconnectByOtherPeer(PeerBase otherPeer, OperationRequest otherRequest, SendParameters sendParameters)
{
this.ExitWorld();
// disconnect peer after the exit world event is sent
this.Peer.RequestFiber.Enqueue(() => this.Peer.RequestFiber.Enqueue(this.Peer.Disconnect));
// continue execution of other request
PeerHelper.InvokeOnOperationRequest(otherPeer, otherRequest, sendParameters);
}
示例9: SocketUdpNativeDllImport
public SocketUdpNativeDllImport(PeerBase npeer) : base(npeer)
{
if (this.ReportDebugOfLevel(DebugLevel.ALL))
{
this.Listener.DebugReturn(DebugLevel.ALL, "SocketWrapper: UDP, Unity Android Native.");
}
this.Protocol = ConnectionProtocol.Udp;
this.PollReceive = false;
}
示例10: SocketUdp
public SocketUdp(PeerBase npeer) : base(npeer)
{
if (this.ReportDebugOfLevel(DebugLevel.ALL))
{
this.Listener.DebugReturn(DebugLevel.ALL, "CSharpSocket: UDP, Unity3d.");
}
this.Protocol = ConnectionProtocol.Udp;
this.PollReceive = false;
}
示例11: SocketWebTcp
public SocketWebTcp(PeerBase npeer) : base(npeer)
{
ServerAddress = npeer.ServerAddress;
if (this.ReportDebugOfLevel(DebugLevel.INFO))
{
Listener.DebugReturn(DebugLevel.INFO, "new SocketWebTcp() " + ServerAddress);
}
Protocol = ConnectionProtocol.Tcp;
PollReceive = false;
}
示例12: UnsubscribeCounter
/// <summary>
/// The client stops receiving counter updates from the PhotonApplication.CounterPublisher.
/// </summary>
public static OperationResponse UnsubscribeCounter(PeerBase peer, OperationRequest request)
{
var mmoPeer = (MmoPeer)peer;
if (mmoPeer.CounterSubscription == null)
{
return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperation, DebugMessage = "not subscribed" };
}
mmoPeer.CounterSubscription.Dispose();
mmoPeer.CounterSubscription = null;
return new OperationResponse(request.OperationCode);
}
示例13: OperationEnterWorld
public OperationResponse OperationEnterWorld(PeerBase peer, OperationRequest request, SendParameters sendParameters)
{
var operation = new EnterWorld(peer.Protocol, request);
if (!operation.IsValid)
{
return new OperationResponse(request.OperationCode) { ReturnCode = (int)ErrorCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() };
}
MmoWorld world = MmoWorld.Instance;
var actor = new MmoActor(peer, world, interestArea);
var avatar = new MmoItem(world, operation.Position, operation.Rotation, operation.Properties, actor, operation.Username, (byte)ItemType.Avatar);
while (world.ItemCache.AddItem(avatar) == false)
{
Item otherAvatarItem;
if (world.ItemCache.TryGetItem(avatar.Type, avatar.Id, out otherAvatarItem))
{
avatar.Dispose();
actor.Dispose();
interestArea.Dispose();
((Peer)((MmoItem)otherAvatarItem).Owner.Peer).DisconnectByOtherPeer(this, request, sendParameters);
// request continued later, no response here
return null;
}
}
// init avatar
actor.AddItem(avatar);
actor.Avatar = avatar;
((Peer)peer).SetCurrentOperationHandler(actor);
// set return values
var responseObject = new EnterWorldResponse
{
};
// send response; use item channel to ensure that this event arrives before any move or subscribe events
var response = new OperationResponse(request.OperationCode, responseObject);
sendParameters.ChannelId = Settings.ItemEventChannel;
peer.SendOperationResponse(response, sendParameters);
avatar.Spawn(operation.Position);
// response already sent
return null;
}
示例14: AddSubscription
public override IGameListSubscription AddSubscription(PeerBase peer, Hashtable gamePropertyFilter, int maxGameCount)
{
if (gamePropertyFilter == null)
{
gamePropertyFilter = new Hashtable(0);
}
GameChannel gameChannel;
var key = new GameChannelKey(gamePropertyFilter);
if (!this.GameChannels.TryGetValue(key, out gameChannel))
{
gameChannel = new GameChannel(this, key);
this.GameChannels.Add(key, gameChannel);
}
return gameChannel.AddSubscription(peer, maxGameCount);
}
示例15: OnOperationRequest
public OperationResponse OnOperationRequest(PeerBase peer, OperationRequest operationRequest, SendParameters sendParameters)
{
switch ((OperationCode)operationRequest.OperationCode)
{
case OperationCode.EnterWorld:
return this.OperationEnterWorld(peer, operationRequest, sendParameters);
case OperationCode.ExitWorld:
case OperationCode.Move:
return InvalidOperation(operationRequest);
}
return new OperationResponse(operationRequest.OperationCode)
{
ReturnCode = (int)ErrorCode.OperationNotSupported,
DebugMessage = "OperationNotSupported: " + operationRequest.OperationCode
};
}