Hi,大家好,我是《Lua解释器构建:从虚拟机到编译器》(机械工业出版社)的作者,欢迎大家关注我的新书~~
京东购买链接点击商店
manistein / sparkserver Goto Github PK
View Code? Open in Web Editor NEWSparkServer是一个参照skynet设计的C#服务端框架,能够无缝整合到skynet集群机制中,也能自行组网,构建只有SparkServer节点的集群
License: MIT License
SparkServer是一个参照skynet设计的C#服务端框架,能够无缝整合到skynet集群机制中,也能自行组网,构建只有SparkServer节点的集群
License: MIT License
Hi,大家好,我是《Lua解释器构建:从虚拟机到编译器》(机械工业出版社)的作者,欢迎大家关注我的新书~~
京东购买链接点击商店
int packetSize = buffer.Length;
// big endian
m_writeCache[0] = (byte)(packetSize >> 8);
m_writeCache[1] = (byte)(packetSize & 0xff);
如果packetSize刚好位64*1024,那cache[0] = 0, cache[1]=0,那cache的前两位是用来存packetsize的,packetsize不就为0了吗?不知道是不是自己理解有问题
测试代码
using System;
namespace BigEndian
{
public class Program
{
static void Main()
{
byte[] cache = new byte[2];
int packetSize = 64*1024;
//Console.WriteLine(Convert.ToString(packetSize, 2).PadLeft(32, '0'));
var bytes = BitConverter.GetBytes(packetSize);
Console.WriteLine("PacketSize "+BitConverter.ToString(bytes));
int tmp = packetSize >> 8;
Console.WriteLine(" >> 8 " + BitConverter.ToString(BitConverter.GetBytes(tmp)));
tmp = packetSize & 0xff;
Console.WriteLine(" 0xff " + BitConverter.ToString(BitConverter.GetBytes(tmp)));
cache[0] = (byte)(packetSize >> 8);
cache[1] = (byte)(packetSize & 0xff);
Console.WriteLine("Cache "+BitConverter.ToString(cache));
}
}
}
测试结果:
PacketSize 00-00-01-00
>> 8 00-01-00-00
0xff 00-00-00-00
Cache 00-00
我按照readme上的做法完成后尝试编译得到了这个问题
/usr/lib/mono/msbuild/15.0/bin/Microsoft.CSharp.CurrentVersion.targets(331,5): error MSB4019: The imported project "/usr/lib/mono/msbuild/15.0/bin/Roslyn/Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [/home/xia0lei/elemental2_server/SparkServer/spark-server/server/SparkServer.csproj]
环境:centos 7
Gateway测试用例中,客户端发送的字符串为"HelloHe...",而收到的是一段Base64编码的字符串,内容完全不同。
经查,原因在GateWayCase.cs中
SocketData函数中
`
List<byte[]> buffList = new List<byte[]>();
buffList.Add(Encoding.ASCII.GetBytes(data.buffer));
message.Buffers = buffList;`
改为
`
List<byte[]> buffList = new List<byte[]>();
buffList.Add(Convert.FromBase64String(data.buffer));
message.Buffers = buffList;`
即可。
(本来想提PR,但网络代理有点问题速度太慢)
我正在寻找一个c#的actor轻量服务器框架,也是因为战斗主要是用c#写的,您写的这个很适合我的需求,我在研读的过程中有一个关于项目实用的问题,您的gateclientcase里面我看到发送数据包是使用了框架里面的TcpClient类,那这个类中包含了Session, InBoundManager和OutBoundManager相关的类,我想请问下,就是使用发送数据包时,也是让Unity客户端的同学去使用TCPClient相关的类的吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.