Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Created August 8, 2017 03:46
Show Gist options
  • Select an option

  • Save dimmduh/90460dcf70adc4d930fc1ec50697e587 to your computer and use it in GitHub Desktop.

Select an option

Save dimmduh/90460dcf70adc4d930fc1ec50697e587 to your computer and use it in GitHub Desktop.
MNF ProtobufDispatcher
using System.Collections;
using System.Collections.Generic;
using MNF;
using UnityEngine;
public class ProtobufDispatcher : DefaultDispatchHelper<ProtobufSession>
{
public override bool OnInit()
{
if (ExportFunctionFromEnum<ProtobufMessageDefine.ENUM_TCP_MESSAGES>() == false)
return false;
return true;
}
private int onTCP_NEW_ADD_MESSAGE(TCPSession session, object message)
{
// var udpMessageInfo = (UdpMessageInfo)message;
// LogManager.Instance.Write("{0}, {1}, {2}", udpMessageInfo.RemoteIP, udpMessageInfo.UdpMessage, udpMessageInfo.IsSendMe);
var data = (byte[]) message;
Debug.Log("Income22: " + data.Length);
Debug.Log("2: " + data[2]);
return 0;
}
}
public class ProtobufMessageDefine
{
public enum ENUM_TCP_MESSAGES
{
TCP_NEW_ADD_MESSAGE,
TCP_SHOT
}
public class PACK_TCP_NEW_ADD_MESSAGE
{
public PACK_TCP_NEW_ADD_MESSAGE()
{
Debug.Log("PACK_TCP_NEW_ADD_MESSAGE");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment