本文整理匯總了C#中RakNet.RakString.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# RakString.Dispose方法的具體用法?C# RakString.Dispose怎麽用?C# RakString.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類RakNet.RakString
的用法示例。
在下文中一共展示了RakString.Dispose方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//.........這裏部分代碼省略.........
Console.WriteLine(testFilterQuery.cellValue);
Console.WriteLine(testFilterQuery.columnIndex);
Console.WriteLine(testFilterQuery.columnName);
Console.WriteLine(testFilterQuery.operation);
//FLP_Printf
Console.WriteLine("FLP_Printf");
FLP_Printf testFLP_Printf = new FLP_Printf();
testFLP_Printf.OnAddFilesFromDirectoryStarted(testFileList, "./");
testFLP_Printf.OnDirectory(testFileList, "./", 9);
testFLP_Printf.OnFile(testFileList, "./", "nonexist", 22);
testFLP_Printf.OnFilePush("./Nonexist", 99, 99, 99, true, RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS);
//FullyConnectedMesh2
Console.WriteLine("FullyConnectedMesh2");
FullyConnectedMesh2 testFullyConnectedMesh2 = FullyConnectedMesh2.GetInstance();
testClient.AttachPlugin(testFullyConnectedMesh2);
testFullyConnectedMesh2.AddParticipant(testServer.GetGuidFromSystemAddress(RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS));
Console.WriteLine(testFullyConnectedMesh2.GetConnectedHost());
Console.WriteLine(testFullyConnectedMesh2.GetConnectedHostAddr());
Console.WriteLine(testFullyConnectedMesh2.GetHostSystem());
Console.WriteLine(testFullyConnectedMesh2.GetParticipantCount());
uint outUint;
testFullyConnectedMesh2.GetParticipantCount(out outUint);
Console.WriteLine(outUint);
Console.WriteLine(testFullyConnectedMesh2.IsConnectedHost());
Console.WriteLine(testFullyConnectedMesh2.IsHostSystem());
testFullyConnectedMesh2.ResetHostCalculation();
testFullyConnectedMesh2.SetAutoparticipateConnections(true);
workingRakStringCopy = "none";
testFullyConnectedMesh2.SetConnectOnNewRemoteConnection(false, workingRakStringCopy);
workingRakStringCopy.Dispose();
//MessageFilter
Console.WriteLine("MessageFilter");
MessageFilter testMessageFilter = new MessageFilter();
testClient.AttachPlugin(testMessageFilter);
testMessageFilter.SetSystemFilterSet(testClient.GetSystemAddressFromIndex(0), 99);
testMessageFilter.SetAllowRPC(false, "test", 99);
testMessageFilter.SetAllowMessageID(true, 99, 99, 99);
testMessageFilter.SetAutoAddNewConnectionsToFilter(99);
testMessageFilter.SetFilterMaxTime(99, false, 0, 98);
testMessageFilter.GetSystemFilterSet(testClient.GetSystemAddressFromIndex(0));
testMessageFilter.GetSystemCount(99);
testMessageFilter.GetSystemByIndex(99, 0);
testMessageFilter.GetFilterSetIDByIndex(0);
testMessageFilter.GetFilterSetCount();
testMessageFilter.DeleteFilterSet(99);
//NatPunchthroughClient
Console.WriteLine("NatPunchthroughClient");
NatPunchthroughClient testNatPunchthroughClient = new NatPunchthroughClient();
testClient.AttachPlugin(testNatPunchthroughClient);
testNatPunchthroughClient.GetPunchthroughConfiguration();
testNatPunchthroughClient.GetUPNPExternalPort();
workingRakStringCopy = testNatPunchthroughClient.GetUPNPInternalAddress();
workingRakStringCopy.Dispose();
testNatPunchthroughClient.GetUPNPInternalPort();
testNatPunchthroughClient.OpenNAT(testServer.GetGuidFromSystemAddress(RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS), testClient.GetSystemAddressFromIndex(0));
NatPunchthroughDebugInterface_PacketLogger testNatPunchthroughDebugInterface_PacketLogger = new NatPunchthroughDebugInterface_PacketLogger();
testNatPunchthroughClient.SetDebugInterface(testNatPunchthroughDebugInterface_PacketLogger);
//NatPunchthroughDebugInterface_PacketLogger
示例2: Main
static void Main(string[] args)
{
if (!File.Exists("RakNet.dll"))
{
Console.WriteLine("The SWIG build of the DLL has not been copied to the executable directory\nCopy from Swig/SwigWindowsCSharpSample/SwigTestApp/bin/X86/Debug/RakNet.dll to\nSwigWindowsCSharpSample/SwigTestApp/bin/Debug/RakNet.dll\nPress enter to quit.");
Console.Read();
return;
}
try
{
RakString dllCallTest = new RakString();
}
catch (Exception e)
{
Console.WriteLine("DLL issue\nAdd SwigOutput/CplusDLLIncludes/RakNetWrap.cxx to the project\nDLL_Swig/RakNet.sln and rebuild.\nPress enter to quit.");
Console.Read();
return;
}
Packet testPacket;
int loopNumber;
BitStream stringTestSendBitStream = new BitStream();
BitStream rakStringTestSendBitStream = new BitStream();
BitStream receiveBitStream = new BitStream();
String holdingString;
TimeSpan startTimeSpan;
RakString rakStringTest = new RakString();
RakPeerInterface testClient = RakPeer.GetInstance();
testClient.Startup(1, new SocketDescriptor(60000, "127.0.0.1"), 1);
RakPeerInterface testServer = RakPeer.GetInstance();
testServer.Startup(1, new SocketDescriptor(60001, "127.0.0.1"), 1);
testServer.SetMaximumIncomingConnections(1);
Console.WriteLine("Send and receive loop using BitStream.\nBitStream read done into RakString");
testClient.Connect("127.0.0.1", 60001, "", 0);
String sendString = "The test string";
stringTestSendBitStream.Write((byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
stringTestSendBitStream.Write(sendString);
RakString testRakString = new RakString("Test RakString");
rakStringTestSendBitStream.Write((byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
rakStringTestSendBitStream.Write(testRakString);
startTimeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1));
loopNumber = 0;
while (startTimeSpan.TotalSeconds + 5 > (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds)
{
testPacket = testServer.Receive();
if (testPacket != null && testPacket.data[0] == (byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM)
{
receiveBitStream.Reset();
receiveBitStream.Write(testPacket.data, testPacket.length);
receiveBitStream.IgnoreBytes(1);
receiveBitStream.Read(rakStringTest);
Console.WriteLine("Loop number: " + loopNumber + "\nData: " + rakStringTest.C_String());
}
testServer.DeallocatePacket(testPacket);
loopNumber++;
System.Threading.Thread.Sleep(50);
testClient.Send(rakStringTestSendBitStream, PacketPriority.LOW_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, new AddressOrGUID(new SystemAddress("127.0.0.1", 60001)), false);
}
Console.WriteLine("String send and receive loop using BitStream.\nBitStream read done into String");
SystemAddress[] remoteSystems;
ushort numberOfSystems=1;
testServer.GetConnectionList(out remoteSystems, ref numberOfSystems);
startTimeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1));
loopNumber = 0;
while (startTimeSpan.TotalSeconds + 5 > (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds)
{
testPacket = testServer.Receive();
if (testPacket != null && testPacket.data[0] == (byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM)
{
receiveBitStream.Reset();
receiveBitStream.Write(testPacket.data, testPacket.length);
receiveBitStream.IgnoreBytes(1);
receiveBitStream.Read(out holdingString);
Console.WriteLine("Loop number: " + loopNumber + "\nData: " + holdingString);
}
testServer.DeallocatePacket(testPacket);
loopNumber++;
System.Threading.Thread.Sleep(50);
SystemAddress sa = RakNet.RakNet.UNASSIGNED_SYSTEM_ADDRESS;
testClient.Send(stringTestSendBitStream, PacketPriority.LOW_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, new AddressOrGUID(new SystemAddress("127.0.0.1", 60001)), false);
}
//If RakString is not freed before program exit it will crash
rakStringTest.Dispose();
testRakString.Dispose();
RakPeer.DestroyInstance(testClient);
RakPeer.DestroyInstance(testServer);
//.........這裏部分代碼省略.........
示例3: Main
static void Main(string[] args)
{
Packet testPacket;
int loopNumber;
BitStream stringTestSendBitStream = new BitStream();
BitStream rakStringTestSendBitStream = new BitStream();
BitStream receiveBitStream = new BitStream();
String holdingString;
TimeSpan startTimeSpan;
RakString rakStringTest = new RakString();
RakPeerInterface testClient = RakPeer.GetInstance();
testClient.Startup(1, new SocketDescriptor(60000, "127.0.0.1"), 1);
RakPeerInterface testServer = RakPeer.GetInstance();
testServer.Startup(1, new SocketDescriptor(60001, "127.0.0.1"), 1);
testServer.SetMaximumIncomingConnections(1);
Console.WriteLine("Press enter to start RakString send and receive loop using BitStream.\nBitStream read done into RakString");
Console.WriteLine("Loop will run for 15 seconds");
Console.ReadLine();
testClient.Connect("127.0.0.1", 60001, "", 0);
String sendString = "The test string";
stringTestSendBitStream.Write((byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
stringTestSendBitStream.Write(sendString);
RakString testRakString = new RakString("Test RakString");
rakStringTestSendBitStream.Write((byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM);
rakStringTestSendBitStream.Write(testRakString);
startTimeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1));
loopNumber = 0;
while (startTimeSpan.TotalSeconds + 15 > (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds)
{
testPacket = testServer.Receive();
if (testPacket != null && testPacket.data[0] == (byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM)
{
receiveBitStream.Reset();
receiveBitStream.Write(testPacket.data, testPacket.length);
receiveBitStream.IgnoreBytes(1);
receiveBitStream.Read(rakStringTest);
Console.WriteLine("Loop number: " + loopNumber + "\nData: " + rakStringTest.C_String());
}
testServer.DeallocatePacket(testPacket);
loopNumber++;
System.Threading.Thread.Sleep(50);
testClient.Send(rakStringTestSendBitStream, PacketPriority.LOW_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, new AddressOrGUID(new SystemAddress("127.0.0.1", 60001)), false);
}
Console.WriteLine("Press enter to start String send and receive loop using BitStream.\nBitStream read done into String");
Console.WriteLine("Loop will run for 15 seconds");
Console.ReadLine();
startTimeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1));
loopNumber = 0;
while (startTimeSpan.TotalSeconds + 15 > (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds)
{
testPacket = testServer.Receive();
if (testPacket != null && testPacket.data[0] == (byte)DefaultMessageIDTypes.ID_USER_PACKET_ENUM)
{
receiveBitStream.Reset();
receiveBitStream.Write(testPacket.data, testPacket.length);
receiveBitStream.IgnoreBytes(1);
receiveBitStream.Read(out holdingString);
Console.WriteLine("Loop number: " + loopNumber + "\nData: " + holdingString);
}
testServer.DeallocatePacket(testPacket);
loopNumber++;
System.Threading.Thread.Sleep(50);
testClient.Send(stringTestSendBitStream, PacketPriority.LOW_PRIORITY, PacketReliability.RELIABLE_ORDERED, (char)0, new AddressOrGUID(new SystemAddress("127.0.0.1", 60001)), false);
}
//If RakString is not freed before program exit it will crash
rakStringTest.Dispose();
testRakString.Dispose();
RakPeer.DestroyInstance(testClient);
RakPeer.DestroyInstance(testServer);
Console.WriteLine("Demo complete. Press Enter.");
Console.Read();
}