本文整理汇总了C#中EndianBinaryReader.ReadStruct方法的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryReader.ReadStruct方法的具体用法?C# EndianBinaryReader.ReadStruct怎么用?C# EndianBinaryReader.ReadStruct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndianBinaryReader
的用法示例。
在下文中一共展示了EndianBinaryReader.ReadStruct方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Listen
private void Listen()
{
#if OFFLINE
{
var x = @"C:\Users\James\Desktop\convo.raw";
using (var fs = File.OpenRead(x))
{
using (Reader = new EndianBinaryReader(new LittleEndianBitConverter(), fs))
{
Palace = new ClientPalace(this);
while (fs.Position < fs.Length)
{
var cm = Reader.ReadStruct<ClientMessage>();
HandleMessage(cm);
}
foreach (var bt in blowthrus)
{
using (var ws = File.OpenWrite(@"C:\Users\James\Desktop\blowthrus" + blowthrus.IndexOf(bt) + ".raw"))
{
foreach (var b in bt)
ws.WriteByte(b);
ws.Flush();
}
}
}
}
}
#endif
while (!listenerToken.IsCancellationRequested)
{
try
{
_connection = new TcpClient(targetUri.Host, targetUri.Port);
Palace = new ClientPalace(this);
using (var stream = _connection.GetStream())
{
Handshake(stream, reset);
using (Reader)
using (Writer)
{
//var op_msg = new MH_SMsg("This client is running Taj DEBUG build. Please notify Scorpion of any questions or concerns.");
//op_msg.Write(Writer);
//Debug.WriteLine("OP_SMSG sent");
//var timer = new Timer(o => { connection.Close(); }, null, 6000, 3000);
Connected(this, new EventArgs());
while (!listenerToken.IsCancellationRequested)
{
//try
//{
var msg = Reader.ReadStruct<ClientMessage>();
Debug.WriteLine("Message: " + Enum.GetName(typeof(MessageTypes), msg.eventType));
Debug.WriteLine("{");
Debug.Indent();
HandleMessage(msg);
Debug.Unindent();
Debug.WriteLine("}");
//}
//catch (AggregateException ae)
//{
// foreach (var ie in ae.InnerExceptions)
// if (ie is ObjectDisposedException || ie is OperationCanceledException)
// return;
// throw;
//}
}
if (_connection.Connected)
Signoff();
}
}
Debug.WriteLine("Listening ended");
}
catch (IOException e)
{
Trace.TraceError(e.ToString());
}
finally
{
if (_connection != null)
_connection.Close();
}
}
}