/// <summary> /// /// </summary> /// <param name="bridge"></param> /// <param name="p2pMessage"></param> /// <returns></returns> public bool ProcessP2PData(P2PBridge bridge, P2PMessage p2pMessage) { ResetTimeoutTimer(); // Keep track of the remote identifier remoteIdentifier = (p2pMessage.Version == P2PVersion.P2PV2) ? p2pMessage.Header.Identifier + p2pMessage.Header.MessageSize : p2pMessage.Header.Identifier; if (status == P2PSessionStatus.Closed || status == P2PSessionStatus.Error) { Trace.WriteLineIf(Settings.TraceSwitch.TraceWarning, String.Format("P2PSession {0} received message whilst in '{1}' state", sessionId, status), GetType().Name); return(false); } if (p2pApplication == null) { Trace.WriteLineIf(Settings.TraceSwitch.TraceWarning, String.Format("P2PSession {0}: Received message for P2P app, but it's either been disposed or not created", sessionId), GetType().Name); return(false); } else { // Application data if (p2pMessage.Header.MessageSize > 0 && p2pMessage.Header.SessionId > 0) { bool reset = false; byte[] appData = new byte[0]; if (p2pMessage.Header.MessageSize == 4 && BitUtility.ToInt32(p2pMessage.InnerBody, 0, true) == 0) { reset = true; } else { appData = new byte[p2pMessage.InnerBody.Length]; Buffer.BlockCopy(p2pMessage.InnerBody, 0, appData, 0, appData.Length); } if (p2pMessage.Version == P2PVersion.P2PV2 && (TFCombination.First == (p2pMessage.V2Header.TFCombination & TFCombination.First))) { reset = true; } return(p2pApplication.ProcessData(bridge, appData, reset)); } return(false); } }