本文整理汇总了C#中System.IO.PacketWriter类的典型用法代码示例。如果您正苦于以下问题:C# PacketWriter类的具体用法?C# PacketWriter怎么用?C# PacketWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketWriter类属于System.IO命名空间,在下文中一共展示了PacketWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnRoomEvent
public static void OnRoomEvent(this GameServer server, StoSMessage msg, RoomInfo info){
using(PacketWriter writer = new PacketWriter(2)){
writer.Write((ushort)msg);
//length
writer.Write((ushort)1);
writer.WriteUnicode(info.Name, 20);
writer.WriteUnicode(info.Pwd, 20);
writer.Write((byte)info.Rule);
writer.Write((byte)info.Mode);
writer.Write(info.IsStart);
writer.WriteUnicode(info.Lflist, 60);
writer.Write(info.Warring);
writer.Write(info.StartLP);
writer.Write((ushort)info.players.Length);
for(int i =0; i<info.players.Length;i++){
writer.WriteUnicode(info.players[i], 20);
}
writer.Write((ushort)info.observers.Count);
for(int i =0; i<info.observers.Count;i++){
writer.WriteUnicode(info.observers[i], 20);
}
//string str = Tool.ToJson(info);
//byte[] bs = Encoding.Unicode.GetBytes(str);
//writer.Write(bs);
writer.Use();
//Send(server.LocalClient, writer.Content);
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:28,代码来源:RoomHelper.cs
示例2: DoShipList
private void DoShipList(Socket socket)
{
var writer = new PacketWriter();
var entries = new List<ShipEntry>();
for (var i = 1; i < 11; i++)
{
var entry = new ShipEntry
{
order = (ushort)i,
number = (uint)i,
status = ShipStatus.Online,
name = String.Format("Ship{0:0#}", i),
ip = PolarisApp.BindAddress.GetAddressBytes()
};
entries.Add(entry);
}
writer.WriteStruct(new PacketHeader(Marshal.SizeOf(typeof(ShipEntry)) * entries.Count + 12, 0x11, 0x3D, 0x4,
0x0));
writer.WriteMagic((uint)entries.Count, 0xE418, 81);
foreach (var entry in entries)
writer.WriteStruct(entry);
writer.Write((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds);
writer.Write(1);
socket.Send(writer.ToArray());
socket.Close();
}
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:29,代码来源:QueryServer.cs
示例3: OnRoomClose
public static void OnRoomClose(GameRoom room){
using (PacketWriter writer=new PacketWriter(2)){
writer.Write((byte)RoomMessage.RoomClose);
writer.WriteUnicode(room.Config.Name, 20);
Send(writer.Content);
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:7,代码来源:ServerApi.cs
示例4: OnServerClose
public static void OnServerClose(this RoomServer roomServer, DuelServer server)
{
using (PacketWriter writer = new PacketWriter(2))
{
writer.Write((byte)RoomMessage.ServerClose);
writer.Write(server.Port);
DuelServer srv = roomServer.GetMinServer();
lock (srv.AsyncLock)
{
srv.Count = 0;
}
if (srv != null)
{
//特殊处理
writer.Write(srv.Port);
writer.Write(srv.NeedAuth);
//session.ServerInfo = srv;
lock (roomServer.Clients)
{
foreach (Session client in roomServer.Clients.Values)
{
if (client.ServerInfo != null && client.ServerInfo.Port == server.Port)
{
client.ServerInfo = srv;
client.Send(writer.Content);
}
}
}
}
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:32,代码来源:RoomEvent.cs
示例5: GenerateSpawnBlob
public override byte[] GenerateSpawnBlob()
{
PacketWriter writer = new PacketWriter();
writer.WriteStruct(Header);
writer.WritePosition(Position);
writer.Write((UInt16)0);
writer.WriteFixedLengthASCII(Name, 0x20);
writer.Write(0); // Padding?
writer.Write(new byte[0xC]); // Unknown, usually zero
writer.Write((UInt16)0);
writer.Write((UInt16)0);
writer.Write((UInt32)0);
writer.Write((UInt32)0);
writer.Write((UInt32)1101004800); // Always this
writer.Write((UInt32)0);
writer.Write((UInt32)0);
writer.Write((UInt32)0);
writer.Write((UInt32)1);
writer.WriteMagic(1, 0x9FCD, 0xE7);
writer.Write((UInt32)0);
return writer.ToArray();
}
开发者ID:ChowZenki,项目名称:PolarisServer,代码行数:30,代码来源:PSOObject.cs
示例6: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
var writer = new PacketWriter();
writer.Write((uint) 0);
context.SendPacket(0x11, 0x55, 0x0, writer.ToArray());
}
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:7,代码来源:SimplePackets.cs
示例7: OnSendServerInfo
public static void OnSendServerInfo(this RoomServer roomServer, Session session)
{
using (PacketWriter writer = new PacketWriter(2))
{
writer.Write((byte)RoomMessage.Info);
writer.Write(roomServer.GetChatPort());
DuelServer srv = roomServer.GetMinServer();
lock (srv.AsyncLock)
{
srv.Count++;
}
if (srv != null)
{
session.ServerInfo = srv;
writer.Write(srv.Port);
writer.Write(srv.NeedAuth);
}
else
{
writer.Write(0);
writer.Write((byte)0);
}
writer.WriteUnicode(session.Token, 32);
session.Send(writer.Content);
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:26,代码来源:RoomEvent.cs
示例8: RicePacket
public RicePacket(ushort id)
{
Writer = new PacketWriter(new MemoryStream());
ID = id;
Writer.Write(id);
}
开发者ID:oxykidz,项目名称:RiceEmu,代码行数:7,代码来源:RicePacket.cs
示例9: LobbyError
public static void LobbyError(this Session session, string message)
{
using (PacketWriter join = new PacketWriter(2))
{
join.Write((byte)RoomMessage.JoinGame);
join.Write(0U);
join.Write((byte)0);
join.Write((byte)0);
join.Write(0);
join.Write(0);
join.Write(0);
// C++ padding: 5 bytes + 3 bytes = 8 bytes
for (int i = 0; i < 3; i++)
join.Write((byte)0);
join.Write(0);
join.Write((byte)0);
join.Write((byte)0);
join.Write((short)0);
session.Send(join, false);
}
using (PacketWriter enter = new PacketWriter(2))
{
enter.Write((byte)RoomMessage.HsPlayerEnter);
enter.WriteUnicode("[err]" + message, 20);
enter.Write((byte)0);
session.Send(enter);
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:29,代码来源:ClinetEvent.cs
示例10: SendRecvPacket
public SendRecvPacket(int id, string name)
{
Id = id;
Name = name;
Stream = PacketWriter.CreateInstance(Length);
Stream.Write(id);
Stream.Write((short) 0);
}
开发者ID:TormentedEmu,项目名称:OpenUO,代码行数:8,代码来源:SendRecvPacket.cs
示例11: SendPacket
/// <summary>
/// Creates an instance of a packet
/// </summary>
/// <param name="id">the Id, or Command that identifies the packet</param>
/// <param name="name">The name of the packet</param>
public SendPacket(int id, string name)
{
m_Id = id;
m_Name = name;
Stream = PacketWriter.CreateInstance(m_Length);
Stream.Write((byte)id);
Stream.Write((short)0);
}
开发者ID:msx752,项目名称:UltimaXNA,代码行数:13,代码来源:SendPacket.cs
示例12: OnPlayerLeave
public static void OnPlayerLeave(GameSession player, GameRoom room){
if (player.Name == null || player.Name.StartsWith("[AI]")) return;
using (PacketWriter writer=new PacketWriter(2)){
writer.Write((byte)RoomMessage.PlayerLeave);
writer.WriteUnicode(player.Name, 20);
writer.WriteUnicode(room.Config.Name, 20);
Send(writer.Content);
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:9,代码来源:ServerApi.cs
示例13: OnServerInfo
public static void OnServerInfo(GameServer server){
ServerConfig Config = server.Config;
using(PacketWriter writer=new PacketWriter(2)){
writer.Write((byte)RoomMessage.Info);
writer.Write(Config.ServerPort);
writer.Write(Config.isNeedAuth);
Send(writer.Content);
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:9,代码来源:ServerApi.cs
示例14: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
if (context.Character == null)
return;
var reader = new PacketReader(data, position, size);
reader.BaseStream.Seek(0xC, SeekOrigin.Begin);
var channel = reader.ReadUInt32();
var message = reader.ReadUtf16(0x9D3F, 0x44);
if (message.StartsWith(PolarisApp.Config.CommandPrefix))
{
var valid = false;
// Iterate commands
foreach (var command in PolarisApp.ConsoleSystem.Commands)
{
var full = message.Substring(1); // Strip the command chars
var args = full.Split(' ');
if (command.Names.Any(name => args[0].ToLower() == name.ToLower()))
{
command.Run(args, args.Length, full, context);
valid = true;
Logger.WriteCommand(null, "[CMD] {0} issued command {1}", context.User.Username, full);
}
if (valid)
break;
}
if (!valid)
Logger.WriteClient(context, "[CMD] {0} - Command not found", message.Split(' ')[0].Trim('\r'));
}
else
{
Logger.Write("[CHT] <{0}> <{1}>", context.Character.Name, message);
var writer = new PacketWriter();
writer.WritePlayerHeader((uint) context.User.PlayerId);
writer.Write(channel);
writer.WriteUtf16(message, 0x9D3F, 0x44);
data = writer.ToArray();
foreach (var c in Server.Instance.Clients)
{
if (c.Character == null || c.CurrentZone != context.CurrentZone)
continue;
c.SendPacket(0x07, 0x00, 0x44, data);
}
}
}
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:54,代码来源:ChatHandler.cs
示例15: NovacomSocketStream
/// <exception cref="System.IO.IOException" />
internal NovacomSocketStream(TcpClient socket, string cmdUsedForStream)
{
this.socket = socket;
ioStream = this.socket.GetStream();
packetReader = new PacketReader(ioStream);
packetWriter = new PacketWriter(ioStream);
packetMode = true;
outputClosed = false;
inputClosed = false;
this.cmdUsedForStream = cmdUsedForStream;
}
开发者ID:GMMan,项目名称:Novacom-CSharp,代码行数:12,代码来源:NovacomSocketStream.cs
示例16: OnPlayerEnter
public static void OnPlayerEnter(GameSession player, GameRoom room){
if (player.Name==null||player.Name.StartsWith("[AI]")) return;
using(PacketWriter writer=new PacketWriter(2)){
writer.Write((byte)RoomMessage.PlayerEnter);
writer.WriteUnicode(player.Name, 20);
writer.WriteUnicode(room.Config.Name, 20);
Send(writer.Content);
}
string tip = Messages.RandomMessage();
if(!string.IsNullOrEmpty(tip))
player.ServerMessage(Messages.RandomMessage());
}
开发者ID:247321453,项目名称:YgoServer,代码行数:12,代码来源:ServerApi.cs
示例17: OnRoomCreate
public static void OnRoomCreate(GameRoom room){
if(room==null||room.Config==null){
return;
}
using(PacketWriter writer=new PacketWriter(2)){
writer.Write((byte)RoomMessage.RoomCreate);
writer.WriteUnicode(room.Name, 20);
writer.WriteUnicode(room.Config.Name, 20);
writer.WriteUnicode(room.Config.BanList);
Send(writer.Content);
}
}
开发者ID:247321453,项目名称:YgoServer,代码行数:12,代码来源:ServerApi.cs
示例18: DoBlockBalance
private void DoBlockBalance(Socket socket)
{
var writer = new PacketWriter();
writer.WriteStruct(new PacketHeader(0x90, 0x11, 0x2C, 0x0, 0x0));
writer.Write(new byte[0x68 - 8]);
writer.Write(PolarisApp.BindAddress.GetAddressBytes());
writer.Write((UInt16)12205);
writer.Write(new byte[0x90 - 0x6A]);
socket.Send(writer.ToArray());
socket.Close();
}
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:12,代码来源:QueryServer.cs
示例19: WritePacket
public void WritePacket(PacketWriter writer)
{
writer.WriteInt32((int)FailureReason);
if (Fingerprint != null)
writer.WriteString(Fingerprint.ToJson());
else
writer.WriteString(null);
writer.WriteString(HostName);
writer.WriteString(AssetsRootUrl);
writer.WriteString(iTunesUrl);
writer.WriteString(Unknown1);
writer.WriteInt32(RemainingTime);
writer.WriteByte(Unknown2);
writer.WriteByteArray(CompressedFingerprintJson);
writer.WriteString(Unknown3);
writer.WriteString(Unknown4);
File.WriteAllBytes("dump", ((MemoryStream)writer.BaseStream).ToArray());
}
开发者ID:maithanhtan,项目名称:CoCSharp,代码行数:18,代码来源:LoginFailedPacket.cs
示例20: Client
public Client(Server server, SocketClient socket)
{
IsClosed = false;
_server = server;
Socket = socket;
socket.DataReceived += HandleDataReceived;
socket.ConnectionLost += HandleConnectionLost;
_readBuffer = new byte[1024 * 64];
_readBufferSize = 0;
InputArc4 = null;
OutputArc4 = null;
var welcome = new PacketWriter();
welcome.Write((ushort)3);
welcome.Write((ushort)201);
welcome.Write((ushort)0);
welcome.Write((ushort)0);
SendPacket(0x03, 0x08, 0, welcome.ToArray());
}
开发者ID:yos-direct,项目名称:PolarisServer,代码行数:22,代码来源:Client.cs
注:本文中的System.IO.PacketWriter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论