AMessage.cs 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using MongoDB.Bson.Serialization.Attributes;
  2. using ProtoBuf;
  3. namespace Model
  4. {
  5. [BsonKnownTypes(typeof(ARequest))]
  6. [BsonKnownTypes(typeof(AResponse))]
  7. [BsonKnownTypes(typeof(AActorMessage))]
  8. public abstract class AMessage
  9. {
  10. }
  11. [ProtoContract]
  12. [ProtoInclude(10000, typeof(C2R_Login))]
  13. [ProtoInclude(10001, typeof(C2G_LoginGate))]
  14. [ProtoInclude(10002, typeof(C2G_EnterMap))]
  15. [BsonKnownTypes(typeof(AActorRequest))]
  16. public abstract class ARequest : AMessage
  17. {
  18. [ProtoMember(1000)]
  19. [BsonIgnoreIfDefault]
  20. public uint RpcId;
  21. }
  22. /// <summary>
  23. /// 服务端回的RPC消息需要继承这个抽象类
  24. /// </summary>
  25. [ProtoContract]
  26. [ProtoInclude(10000, typeof(R2C_Login))]
  27. [ProtoInclude(10001, typeof(G2C_LoginGate))]
  28. [ProtoInclude(10002, typeof(G2C_EnterMap))]
  29. [BsonKnownTypes(typeof(AActorResponse))]
  30. public abstract class AResponse : AMessage
  31. {
  32. [ProtoMember(1000)]
  33. public uint RpcId;
  34. [ProtoMember(1001)]
  35. public int Error = 0;
  36. [ProtoMember(1002)]
  37. public string Message = "";
  38. }
  39. }