SuperSocket
SuperSocket copied to clipboard
请问从AppSession继承下来的自定义类为什么无法直接调用SendAsync方法,需要转为IAppSession才能
using Google.Protobuf;
using Orleans;
using OrleansBasics;
using SuperSocket;
using SuperSocket.Server;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SocketGate
{
// 会话对象 要接受返回
public class ProtobufSession : AppSession, IPlayerObserver
{
public IPlayer PlayerGrain { get; internal set; }
public IGame GameGrain { get; internal set; }
public void ReceiveMessage(string message)
{
Console.WriteLine(message);
}
public void ReceiveMessage(Message.OpCode opCode, byte[] data)
{
var msg = new byte[4 + data.Length];
Util.GetBytes((ushort)data.Length).CopyTo(msg, 0);
Util.GetBytes(opCode).CopyTo(msg, 2);
data.CopyTo(msg, 4);
//var rm = new ReadOnlyMemory<byte>(msg);
Console.WriteLine($"返回消息 {opCode}");
IAppSession session = (AppSession)this;
session.SendAsync(msg);
}
}
}
There are some concerns regarding package encoding design. For example, some application only allow business logic to send protocol encoded data to remote endpoint. I will review the design soon. Any suggestion would be welcome.