示例#1
0
        // For Pdp sockets, data is stored in the internal buffer as a sequence of packets.
        // The organization in packets must be kept for reading.
        private void addReceivedMessage(AdhocMessage adhocMessage, int port)
        {
            AdhocBufferMessage bufferMessage = new AdhocBufferMessage();

            bufferMessage.Length = adhocMessage.DataLength;
            bufferMessage.macAddress.MacAddress = adhocMessage.FromMacAddress;
            bufferMessage.port   = Modules.sceNetAdhocModule.getClientPortFromRealPort(adhocMessage.FromMacAddress, port);
            bufferMessage.offset = rcvdData;
            adhocMessage.writeDataToMemory(buffer.addr + bufferMessage.offset);

            // Update the timestamp of the peer
            Modules.sceNetAdhocctlModule.hleNetAdhocctlPeerUpdateTimestamp(adhocMessage.FromMacAddress);

            //if (log.DebugEnabled)
            {
                Console.WriteLine(string.Format("Successfully received {0:D} bytes from {1} on port {2:D}({3:D})", bufferMessage.Length, bufferMessage.macAddress, bufferMessage.port, port));
                if (log.TraceEnabled)
                {
                    log.trace(string.Format("Message data: {0}", Utilities.getMemoryDump(buffer.addr + bufferMessage.offset, bufferMessage.Length)));
                }
            }

            rcvdData += bufferMessage.Length;
            rcvdMessages.AddLast(bufferMessage);
        }
示例#2
0
        // For Ptp sockets, data is stored in the internal buffer as a continuous byte stream.
        // The organization in packets doesn't matter.
        private int addReceivedMessage(AdhocMessage adhocMessage, int offset)
        {
            int Length = System.Math.Min(adhocMessage.DataLength - offset, BufSize - RcvdData);
            int addr   = buffer.addr + RcvdData;

            adhocMessage.writeDataToMemory(addr, offset, Length);
            rcvdData += Length;
            //if (log.DebugEnabled)
            {
                if (offset == 0)
                {
                    Console.WriteLine(string.Format("Successfully received message (Length={0:D}, rcvdData={1:D}) {2}", Length, RcvdData, adhocMessage));
                }
                else
                {
                    Console.WriteLine(string.Format("Appending received message (offset={0:D}, Length={1:D}, rcvdData={2:D}) {3}", offset, Length, RcvdData, adhocMessage));
                }
                if (log.TraceEnabled)
                {
                    log.trace(string.Format("Message data: {0}", Utilities.getMemoryDump(addr, Length)));
                }
            }

            return(Length);
        }