void DarkNetwork::SendAll(Buffer buff) { for (size_t i = 0, size = m_peers.size(); i < size; ++i) { Packet pck(buff, m_peers[i].address); Send(pck); } }
void CBTControllerServerSession::GetCurrentConfigName() { TFileName fn; iController.GetConfigName(fn); TPckg<TFileName> pck(fn); TInt err(KErrNone); err = iMessage.Write(0,pck); iMessage.Complete(err); }
void CBTControllerServerSession::SetWiiSpeakerStatusComplete(TControllerDataTypes::TWiiSpeaker aState, TInt aError) { if(iMessage.Function() == TControllerDataTypes::EWiiSpeakerEnabled) { TPckg<TControllerDataTypes::TWiiSpeaker> pck(aState); if(!iMessage.IsNull()) { iMessage.Write(0,pck); iMessage.Complete(aError); } } }
void CBTControllerServerSession::GetSpeakerEnabledComplete(TControllerDataTypes::TWiiSpeaker aEnabled, TInt aError) { if(iMessage.Function() == EWiiSpeakerEnabled) { TPckg<TBool> pck(aEnabled); if(!iMessage.IsNull()) { iMessage.Write(0,pck); iMessage.Complete(aError); } } }
void DarkNetwork::WriteNetworkData() { for (size_t i = 0, size = m_peers.size(); i < size; ++i) { if (m_peers[i].output_msg.size()) { Packet pck(m_peers[i].output_msg, m_peers[i].address); Send(pck); m_peers[i].output_msg.clear(); } } }
void C4GameOptionsList::OptionScenarioParameter::DoDropdownSelChange(int32_t idNewSelection) { // runtime change needs to be synchronized if (!pForDlg->IsPreGame()) { // change possible? if (!::Control.isCtrlHost()) return; // Then initiate an update of the parameters on all clients C4GameLobby::C4PacketSetScenarioParameter pck(ParameterDef->GetID(), idNewSelection); ::Network.Clients.BroadcastMsgToClients(MkC4NetIOPacket(PID_SetScenarioParameter, pck)); } // also process on host (and standalone pre-game) pForDlg->GetParameters()->SetValue(ParameterDef->GetID(), idNewSelection, false); if (pForDlg->IsPreGame()) Update(); }
void CBTControllerServerSession::SetWiiSpeakerStatus(TControllerDataTypes::TWiiSpeaker aState) { TInt err(0); err = iController.SetWiiSpeakerStatus(aState); if(err != KErrNone) { TInt i(0); TPckg<TBool> pck(i); if(!iMessage.IsNull()) { iMessage.Write(0,pck); iMessage.Complete(err); } } }
void CBTControllerServerSession::GetBatteryStatusComplete(TInt aBatteryStatus, TInt aError) { if(iMessage.Function() == EBatteryStatus) { TPckg<TInt> pck(aBatteryStatus); if(!iMessage.IsNull()) { TInt err(KErrNone); TInt bat(aBatteryStatus); TPtr8 ptr( reinterpret_cast<TUint8*>( &bat ), sizeof( bat ), sizeof( bat ) ); err = iMessage.Write(0,ptr,0); iMessage.Complete(aError); } } }
Uint32 PacketReader::newPacket(Uint8* buf, Uint32 size) { Uint32 packet_length = 0; Uint32 am_of_len_read = 0; if (len_received > 0) { if ((int) size < 4 - len_received) { memcpy(len + len_received, buf, size); len_received += size; return size; } else { memcpy(len + len_received, buf, 4 - len_received); am_of_len_read = 4 - len_received; len_received = 0; packet_length = ReadUint32(len, 0); } } else if (size < 4) { memcpy(len, buf, size); len_received = size; return size; } else { packet_length = ReadUint32(buf, 0); am_of_len_read = 4; } if (packet_length == 0) return am_of_len_read; if (packet_length > max_packet_size) { Out(SYS_CON | LOG_DEBUG) << " packet_length too large " << packet_length << endl; error = true; return size; } IncomingPacket::Ptr pck(new IncomingPacket(packet_length)); packet_queue.push_back(pck); return am_of_len_read + readPacket(buf + am_of_len_read, size - am_of_len_read); }
std::vector<InternalPacket*> InternalPacket::fromBinary(uint8* buffer, uint32 size) { std::vector<InternalPacket*> packets; Packet pck(buffer, size); while (pck.getPosition() < pck.getLength()) { InternalPacket* packet = new InternalPacket(); uint8 flags = pck.getByte(); packet->reliability = (flags & 0xE0) >> 5; packet->hasSplit = (flags & 0x10) > 0; packet->length = (uint16)(pck.getShort() + 7) >> 3; /* * From http://www.jenkinssoftware.com/raknet/manual/reliabilitytypes.html * * Default: 0b010 (2) || 0b011 (3) * * 0: UNRELIABLE * 1: UNRELIABLE_SEQUENCED * 2: RELIABLE * 3: RELIABLE_ORDERED * 4: RELIABLE_SEQUENCED * 5: UNRELIABLE_WITH_ACK_RECEIPT * 6: RELIABLE_WITH_ACK_RECEIPT * 7: RELIABLE_ORDERED_WITH_ACK_RECEIPT */ if (packet->reliability == 2 || packet->reliability == 3 || packet->reliability == 4 || packet->reliability == 6 || packet->reliability == 7) { packet->messageIndex = pck.getLTriad(); } if (packet->reliability == 1 || packet->reliability == 3 || packet->reliability == 4 || packet->reliability == 7) { packet->orderIndex = pck.getLTriad(); packet->orderChannel = pck.getByte(); } if (packet->hasSplit) { packet->splitCount = pck.getInt(); packet->splitID = pck.getShort(); packet->splitIndex = pck.getInt(); } packet->buff = pck.getByte(packet->length); packets.push_back(packet); } return packets; }