Skip to content

Commit

Permalink
Update yasio to v4.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Sep 7, 2024
1 parent 273f4ff commit 1bd9b12
Show file tree
Hide file tree
Showing 30 changed files with 4,425 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public enum NetworkEvent
}


public class NetworkServiceManager : Singleton<NetworkServiceManager>
public class NetworkManager : Singleton<NetworkManager>
{
IntPtr _service = IntPtr.Zero;
IntPtr[] _sessions = new IntPtr[1];
Expand Down Expand Up @@ -327,7 +327,7 @@ static void HandleNativeConsolePrint(int level, string msg)
[MonoPInvokeCallback(typeof(YASIO_NI.YNIEventDelegate))]
static void HandleNativeNetworkIoEvent(ref YASIO_NI.IOEvent ev)
{
var nsm = NetworkServiceManager.Instance;
var nsm = NetworkManager.Instance;
Debug.LogFormat("The channel connect_id={0}, bytes_transferred={1}", YASIO_NI.yasio_connect_id(nsm._service, ev.channel),
YASIO_NI.yasio_bytes_transferred(nsm._service, ev.channel));
switch ((YASIO_NI.YEnums)ev.kind)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Assets/Scripts/SampleNetworkPacketHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void HandleEvent(NetworkEvent ev, int cmd, Span<byte> ud, int channel)
reply.uid = msg.uid;
reply.status = 200; // 200 表示success
Span<byte> udReply = reply.encode();
NetworkServiceManager.Instance.SendSerializedMsg(AppProtocol.CMD_LOGIN_RESP, udReply, AppProtocol.SERVER_CHANNEL);
NetworkManager.Instance.SendSerializedMsg(AppProtocol.CMD_LOGIN_RESP, udReply, AppProtocol.SERVER_CHANNEL);
}
else if(cmd == AppProtocol.CMD_LOGIN_RESP)
{ // SampelScene应该是 channel:0 收到
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/SampleScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

public class SampleScene : MonoBehaviour, NetworkEventListener
{
NetworkServiceManager nsm;
NetworkManager nsm;

// Start is called before the first frame update
void Start()
{
Debug.Log("Start Game!");
nsm = NetworkServiceManager.Instance;
nsm = NetworkManager.Instance;
nsm.Start(AppProtocol.MAX_CHANNELS, new SampleNetworkPacketHandler());
nsm.ListenAt("127.0.0.1", AppProtocol.PORT, AppProtocol.SERVER_CHANNEL); // 启动本地TCP服务
nsm.AddEventListener(this);
Expand Down
Loading

0 comments on commit 1bd9b12

Please sign in to comment.