public InboundBufferVec Send(NetworkPipelineContext ctx, InboundBufferVec inboundBuffer, ref bool needsResume, ref bool needsUpdate) { var simulator = new SimulatorUtility(m_SimulatorParams.MaxPacketCount, m_SimulatorParams.MaxPacketSize, m_SimulatorParams.PacketDelayMs); if (inboundBuffer.buffer1.Length + inboundBuffer.buffer2.Length > m_SimulatorParams.MaxPacketSize) { //UnityEngine.Debug.LogWarning("Incoming packet too large for internal storage buffer. Passing through. [buffer=" + (inboundBuffer.buffer1.Length+inboundBuffer.buffer2.Length) + " packet=" + param->MaxPacketSize + "]"); return(inboundBuffer); } var timestamp = ctx.timestamp; // Packet always delayed atm bool delayPacket = true; // Inbound buffer is empty if this is a resumed receive if (delayPacket && inboundBuffer.buffer1.Length > 0) { if (!simulator.DelayPacket(ref ctx, inboundBuffer, ref needsUpdate, timestamp)) { return(inboundBuffer); } } NativeSlice <byte> returnPacket = default(NativeSlice <byte>); if (simulator.GetDelayedPacket(ref ctx, ref returnPacket, ref needsResume, ref needsUpdate, timestamp)) { inboundBuffer.buffer1 = returnPacket; inboundBuffer.buffer2 = default(NativeSlice <byte>); return(inboundBuffer); } return(default(InboundBufferVec)); }
public InboundBufferVec Send(NetworkPipelineContext ctx, InboundBufferVec inboundBuffer, ref bool needsResume, ref bool needsUpdate) { // Request an update to see if a queued packet needs to be resent later or if an ack packet should be sent needsUpdate = true; var header = new ReliableUtility.PacketHeader(); unsafe { var reliable = (ReliableUtility.Context *)ctx.internalProcessBuffer.GetUnsafePtr(); needsResume = ReliableUtility.ReleaseOrResumePackets(ctx); if (inboundBuffer.buffer1.Length > 0) { reliable->LastSentTime = ctx.timestamp; ReliableUtility.Write(ctx, inboundBuffer, ref header); ctx.header.WriteBytes((byte *)&header, UnsafeUtility.SizeOf <ReliableUtility.PacketHeader>()); if (reliable->Resume != ReliableUtility.NullEntry) { needsResume = true; } reliable->PreviousTimestamp = ctx.timestamp; return(inboundBuffer); } if (reliable->Resume != ReliableUtility.NullEntry) { reliable->LastSentTime = ctx.timestamp; var slice = ReliableUtility.ResumeSend(ctx, out header, ref needsResume); ctx.header.Clear(); ctx.header.WriteBytes((byte *)&header, UnsafeUtility.SizeOf <ReliableUtility.PacketHeader>()); inboundBuffer.buffer1 = slice; inboundBuffer.buffer2 = default(NativeSlice <byte>); reliable->PreviousTimestamp = ctx.timestamp; return(inboundBuffer); } if (ReliableUtility.ShouldSendAck(ctx)) { reliable->LastSentTime = ctx.timestamp; ReliableUtility.WriteAckPacket(ctx, ref header); ctx.header.WriteBytes((byte *)&header, UnsafeUtility.SizeOf <ReliableUtility.PacketHeader>()); reliable->PreviousTimestamp = ctx.timestamp; // TODO: Sending dummy byte over since the pipeline won't send an empty payload (ignored on receive) inboundBuffer.buffer1 = new NativeSlice <byte>(ctx.internalProcessBuffer, 0, 1); return(inboundBuffer); } reliable->PreviousTimestamp = ctx.timestamp; return(inboundBuffer); } }
public InboundBufferVec Send(NetworkPipelineContext ctx, InboundBufferVec inboundBuffer, ref bool needsResume, ref bool needsUpdate) { needsResume = false; unsafe { var sequenceId = (int *)ctx.internalProcessBuffer.GetUnsafePtr(); ctx.header.Write((ushort)*sequenceId); *sequenceId = (ushort)(*sequenceId + 1); } return(inboundBuffer); }
public InboundBufferVec Send(NetworkPipelineContext ctx, InboundBufferVec inboundBuffer, ref bool needsResume, ref bool needsUpdate) { return(inboundBuffer); }
public InboundBufferVec InvokeSend(int pipelineStageId, NetworkPipelineContext ctx, InboundBufferVec inboundBuffer, ref bool needsResume, ref bool needsUpdate) { return(inboundBuffer); }
public InboundBufferVec InvokeSend(int pipelineStageId, NetworkPipelineContext ctx, InboundBufferVec inboundBuffer, ref bool needsResume, ref bool needsUpdate) { switch (pipelineStageId) { case 0: return(m_SimulatorPipelineStage.Send(ctx, inboundBuffer, ref needsResume, ref needsUpdate)); case 1: return(m_SimulatorPipelineStageInSend.Send(ctx, inboundBuffer, ref needsResume, ref needsUpdate)); case 2: return(m_NullPipelineStage.Send(ctx, inboundBuffer, ref needsResume, ref needsUpdate)); case 3: return(m_UnreliableSequencedPipelineStage.Send(ctx, inboundBuffer, ref needsResume, ref needsUpdate)); case 4: return(m_ReliableSequencedPipelineStage.Send(ctx, inboundBuffer, ref needsResume, ref needsUpdate)); } return(inboundBuffer); }
private void ProcessSendStage(int startStage, int internalBufferOffset, int internalSharedBufferOffset, PipelineImpl p, ref NativeList <int> resumeQ, ref NetworkPipelineContext ctx, ref InboundBufferVec inboundBuffer, ref bool needsUpdate) { bool needsResume = false; ctx.internalProcessBuffer = Unsafe_GetSliceFromReadOnlyArray(sendBuffer, internalBufferOffset, m_StageCollection.GetSendCapacity(m_StageList[p.FirstStageIndex + startStage])); ctx.internalSharedProcessBuffer = Unsafe_GetSliceFromReadOnlyArray(sharedBuffer, internalSharedBufferOffset, m_StageCollection.GetSharedStateCapacity(m_StageList[p.FirstStageIndex + startStage])); inboundBuffer = m_StageCollection.InvokeSend(m_StageList[p.FirstStageIndex + startStage], ctx, inboundBuffer, ref needsResume, ref needsUpdate); if (needsResume) { resumeQ.Add(startStage); } }