本文整理汇总了C++中raknet::SystemAddress::FromString方法的典型用法代码示例。如果您正苦于以下问题:C++ SystemAddress::FromString方法的具体用法?C++ SystemAddress::FromString怎么用?C++ SystemAddress::FromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::SystemAddress
的用法示例。
在下文中一共展示了SystemAddress::FromString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is_in_same_network
bool Network::is_in_same_network(std::string const& other) const {
RakNet::SystemAddress o;
RakNet::SystemAddress self;
if (o.FromString(other.c_str()) && self.FromString(external_id_.c_str())) {
if (o.EqualsExcludingPort(self)) {
return true;
}
}
return false;
}
示例2: main
int main(void)
{
PortAudioStream *stream;
PaError err;
mute=false;
bool quit;
char ch;
printf("A sample on how to use RakVoice. You need a microphone for this sample.\n");
printf("RakVoice relies on Speex for voice encoding and decoding.\n");
printf("See DependentExtensions/RakVoice/speex-1.1.12 for speex projects.\n");
printf("For windows, I had to define HAVE_CONFIG_H, include win32/config.h,\n");
printf("and include the files under libspeex, except those that start with test.\n");
printf("PortAudio is also included and is used to read and write audio data. You\n");
printf("can substitute whatever you want if you do not want to use portaudio.\n");
printf("Difficulty: Advanced\n\n");
// Since voice is peer to peer, we give the option to use the nat punchthrough client if desired.
RakNet::NatPunchthroughClient natPunchthroughClient;
char port[256];
rakPeer = RakNet::RakPeerInterface::GetInstance();
printf("Enter local port (enter for default): ");
Gets(port, sizeof(port));
if (port[0]==0)
strcpy(port, "60000");
RakNet::SocketDescriptor socketDescriptor(atoi(port),0);
rakPeer->Startup(4, &socketDescriptor, 1);
rakPeer->SetMaximumIncomingConnections(4);
rakPeer->AttachPlugin(&rakVoice);
rakPeer->AttachPlugin(&natPunchthroughClient);
rakVoice.Init(SAMPLE_RATE, FRAMES_PER_BUFFER*sizeof(SAMPLE));
err = Pa_Initialize();
if( err != paNoError ) goto error;
err = Pa_OpenStream(
&stream,
Pa_GetDefaultInputDeviceID(),
1, // Num channels, whatever that means
PA_SAMPLE_TYPE,
NULL,
Pa_GetDefaultOutputDeviceID(),
1, // Num channels
PA_SAMPLE_TYPE,
NULL,
SAMPLE_RATE,
FRAMES_PER_BUFFER, /* frames per buffer */
0, /* number of buffers, if zero then use default minimum */
0, /* paDitherOff, // flags */
PACallback,
0 );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
printf("Support NAT punchthrough? (y/n)? ");
bool useNatPunchthrough;
useNatPunchthrough=(getche()=='y');
printf("\n");
char facilitatorIP[256];
{//Linux fix. Won't compile without it. Because of the goto error above, the scope is ambigious. Make it a block to define that it will not be used after the jump.
//Doesn't change current logic
RakNet::SystemAddress facilitator;
if (useNatPunchthrough)
{
printf("My GUID is %s\n", rakPeer->GetGuidFromSystemAddress(RakNet::UNASSIGNED_SYSTEM_ADDRESS).ToString());
printf("Enter IP of facilitator (enter for default): ");
Gets(facilitatorIP,sizeof(facilitatorIP));
if (facilitatorIP[0]==0)
strcpy(facilitatorIP, "natpunch.jenkinssoftware.com");
facilitator.FromString(facilitatorIP);
facilitator.SetPortHostOrder(NAT_PUNCHTHROUGH_FACILITATOR_PORT);
rakPeer->Connect(facilitatorIP, NAT_PUNCHTHROUGH_FACILITATOR_PORT, 0, 0);
printf("Connecting to facilitator...\n");
}
else
{
printf("Not supporting NAT punchthrough.\n");
}
RakNet::Packet *p;
quit=false;
if (useNatPunchthrough==false)
printf("(Q)uit. (C)onnect. (D)isconnect. C(l)ose voice channels. (M)ute. ' ' for stats.\n");
while (!quit)
{
if (kbhit())
{
ch=getch();
if (ch=='y')
{
quit=true;
}
//.........这里部分代码省略.........