本文整理汇总了C#中Net.Recv方法的典型用法代码示例。如果您正苦于以下问题:C# Net.Recv方法的具体用法?C# Net.Recv怎么用?C# Net.Recv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net
的用法示例。
在下文中一共展示了Net.Recv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
mNet = new Net();
mNet.ConnectionClosed += mNet_ConnectionClosed;
mAudioOut = new AudioOut(mNet.AudioOutStream);
mAudioIn = new AudioIn_KinectXbox(mNet.AudioInStream);
string server = "127.0.0.1";
int port = 31337;
bool retryConnects = true;
//parse arguments
//setup
while (true)
{
//connect to server
if (!mNet.Connected)
{
if (!mNet.Connect(server, port))
{
Console.Write("Err: failed to connect.");
if (retryConnects)
{
Console.WriteLine(" Waiting 5s and then will retry");
Thread.Sleep(5000);
continue;
}
else
{
break;
}
}
}
//enter message loop
Net.EMSG_TYPE msg = mNet.Recv(true); //note this may still block for a short time
switch (msg)
{
case Net.EMSG_TYPE.CONFIG:
Console.WriteLine("Received config, sending ready");
mNet.Send(Net.EMSG_TYPE.READY);
break;
case Net.EMSG_TYPE.START:
Console.WriteLine("Received start");
mAudioIn.Start();
break;
case Net.EMSG_TYPE.STOP:
Console.WriteLine("Received stop");
mAudioIn.Stop();
break;
case Net.EMSG_TYPE.GETBASE:
Console.WriteLine("Received baseline request");
mNet.Send(Net.EMSG_TYPE.BASELINE);
break;
case Net.EMSG_TYPE.AUDIOOUT:
//mAudioOut.DataReceived();
break;
default:
break;
}
//Thread.Sleep(50); //ms
}
}