12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Unity.Networking.Transport;
- namespace KairoEngine.Multiplayer
- {
- public class NetMsg : IComparable<NetMsg>
- {
- public virtual uint code { get { return (uint)NetOpCode.Generic; }}
- public virtual void Serialize(ref DataStreamWriter writer)
- {
- writer.WriteByte((byte)0);
- }
- public virtual void Deserialize(ref DataStreamReader reader)
- {
- }
-
- /// <summary>Send a net message from the server to a client.</summary>
- /// <param name="server">The server sending the message</param>
- /// <param name="netMsg">The actual message to be sent</param>
- /// <param name="writer">The driver writer object</param>
- /// <param name="clientId">The server connection id for the recipient of this message</param>
- public virtual void SendMessage(ServerBehaviour server, NetMsg netMsg, ref DataStreamWriter writer, int clientId) {}
- /// <summary>Send a net message from a client to the server.</summary>
- /// <param name="client">The client sending the message</param>
- /// <param name="netMsg">The actual message to be sent</param>
- /// <param name="writer">The driver writer object</param>
- public virtual void SendMessage(ClientBehaviour client, NetMsg netMsg, ref DataStreamWriter writer) {}
- public virtual NetMsg ReceiveMessage(ServerBehaviour server, ref DataStreamReader stream, int clientId = -1) => null;
- public virtual NetMsg ReceiveMessage(ClientBehaviour client, ref DataStreamReader stream) => null;
- public virtual void ReadMessage(ServerBehaviour server, int clientId = -1) {}
- public virtual void ReadMessage(ClientBehaviour client) {}
- public int CompareTo(NetMsg other)
- {
- throw new NotImplementedException();
- }
- }
- }
|