public bool BroadcastEvent(IPhotonPeer[] peerList, byte[] data, MessageReliablity reliability, byte channelId, MessageContentType messageContentType, out SendResults[] results) { results = new SendResults[peerList.Length]; for (int i = 0; i < peerList.Length; i++) { results[i] = peerList[i].Send(data, reliability, channelId, messageContentType); } return true; }
/// <summary> /// OnReceive callback. /// </summary> /// <param name = "peer"> /// The peer. /// </param> /// <param name = "userData"> /// The user data. /// </param> /// <param name = "data"> /// The data. /// </param> /// <param name = "reliability"> /// The reliability. /// </param> /// <param name = "channelId"> /// The channel id. /// </param> /// /// <param name = "rtt">The round trip time.</param> /// <param name = "rttVariance">The round trip time variance.</param> /// <param name = "numFailures">The number of failures. </param> public void OnReceive( IPhotonPeer peer, object userData, byte[] data, MessageReliablity reliability, byte channelId, int rtt, int rttVariance, int numFailures) { }
/// <summary> /// The send. /// </summary> /// <param name = "data"> /// The data. /// </param> /// <param name = "reliability"> /// The reliability. /// </param> /// <param name = "channelId"> /// The channel id. /// </param> /// <param name="messageContentType">The message content type.</param> /// <returns> /// Always Ok. /// </returns> public SendResults Send(byte[] data, MessageReliablity reliability, byte channelId, MessageContentType messageContentType) { RtsMessageHeader messageType; if (this.Protocol.TryParseMessageHeader(data, out messageType) == false) { throw new InvalidOperationException(); } switch (messageType.MessageType) { case RtsMessageType.Event: { EventData eventData; if (this.Protocol.TryParseEventData(data, out eventData)) { this.fiber.Enqueue( () => { lock (this.syncRootEvents) { this.eventList.Add(eventData); if (log.IsDebugEnabled) { log.DebugFormat( "{0} receives event, {1} total - code {2}", this.SessionId, this.eventList.Count, eventData.Code); } } this.resetEvent.Set(); }); } else { throw new InvalidOperationException(); } break; } case RtsMessageType.OperationResponse: { OperationResponse operationResponse; if (this.Protocol.TryParseOperationResponse(data, out operationResponse)) { this.fiber.Enqueue( () => { lock (this.syncRootResponse) { this.responseList.Add(operationResponse); if (log.IsDebugEnabled) { log.DebugFormat( "{0} receives response, {1} total - code {2}", this.SessionId, this.responseList.Count, operationResponse.OperationCode); } } this.resetResponse.Set(); }); } else { throw new InvalidOperationException(); } break; } } return SendResults.SentOk; }
SendResults IPhotonPeer._InternalBroadcastSend(byte[] data, MessageReliablity reliability, byte channelId, MessageContentType messageContentType) { return new SendResults(); }
/// <summary> /// Send data to the peer. /// </summary> /// <param name = "data"> /// The serialized data. /// </param> /// <param name = "reliability"> /// The reliability. /// </param> /// <param name = "channelId"> /// The channel id. /// </param> /// <returns> /// Always <see cref = "SendResults.SentOk" />. /// </returns> public SendResults Send(byte[] data, MessageReliablity reliability, byte channelId, MessageContentType messageContentType) { RtsMessageHeader messageType; if (this.Protocol.TryParseMessageHeader(data, out messageType) == false) { throw new InvalidOperationException(); } switch (messageType.MessageType) { case RtsMessageType.Event: { EventData eventData; if (this.Protocol.TryParseEventData(data, out eventData)) { Interlocked.Increment(ref eventsReceived); this.eventList.Add(eventData); if (log.IsDebugEnabled) { if (eventData.Parameters.ContainsKey((byte)ParameterCode.ItemId)) { log.DebugFormat( "{0} receives event, {1} total - code {2}, source {3}", this.username, this.eventList.Count, (EventCode)eventData.Code, eventData.Parameters[(byte)ParameterCode.ItemId]); } else { log.DebugFormat( "{0} receives event, {1} total - code {2}", this.username, this.eventList.Count, (EventCode)eventData.Code); } } } else { throw new InvalidOperationException(); } break; } case RtsMessageType.OperationResponse: { OperationResponse response; if (this.Protocol.TryParseOperationResponse(data, out response)) { Interlocked.Increment(ref responseReceived); this.responseList.Add(response); if (response.ReturnCode != (int)ReturnCode.Ok) { log.ErrorFormat( "ERR {0}, OP {1}, DBG {2}", (ReturnCode)response.ReturnCode, (OperationCode)response.OperationCode, response.DebugMessage); } else if (log.IsDebugEnabled) { if (response.Parameters.ContainsKey((byte)ParameterCode.ItemId)) { log.DebugFormat( "{0} receives response, {1} total - code {2}, source {3}", this.username, this.responseList.Count, (OperationCode)response.OperationCode, response.Parameters[(byte)ParameterCode.ItemId]); } else { log.DebugFormat( "{0} receives response, {1} total - code {2}", this.username, this.responseList.Count, (OperationCode)response.OperationCode); } } } else { throw new InvalidOperationException(); } break; } } return SendResults.SentOk; }
void IPhotonApplication.OnReceive(IPhotonPeer photonPeer, object userData, byte[] data, short invocationId, MessageReliablity reliability, byte channelId);