GithubHelp home page GithubHelp logo

johannesdeml / unity-net-core-networking-sockets Goto Github PK

View Code? Open in Web Editor NEW
86.0 8.0 11.0 1.21 MB

NetCoreServer Client implementation for Unity

License: MIT License

C# 93.32% Batchfile 0.56% Ruby 6.01% Shell 0.11%
unity unity3d tcp udp sockets network client-side multiplayer realtime

unity-net-core-networking-sockets's Introduction

Unity .Net Core Networking Client

Unity Editor Screenshot

Lightweight Unity client for NetCoreServer
openupm Unity 2018.1 or later

This is an example for a unity client that works with a NetCoreServer server application. The latest version is built with Unity 2020.3.1f1 and NetCoreServer 5.0.15.

Features

  • Supports SSL, TCP & UDP
  • Client code from NetCoreServer with wrappers for unity usage
  • Precompiled server executables for windows for easy testing
  • Small GC overhead - Usage of MemoryStream
  • Async send and receive - Does not block the Main Thread
  • Low level - just plain UPD/TCP/SSL
  • Tested with local, network and remote server
Platform SSL TCP UDP
Editor ✔️ ✔️ ✔️
Android ✔️ ✔️ ✔️
iOS ✔️ ✔️ ✔️
Windows ✔️ ✔️ ✔️

Installation

You can either install the package through the package manager with OpenUPM (Recommended) or download the scripts as a unity package

OpenUPM

# Install openupm-cli
$ npm install -g openupm-cli

# Enter your unity project folder
$ cd YOUR_UNITY_PROJECT_FOLDER

# Add package to your project
$ openupm openupm add com.deml.netcore-networking

Download

Latest Unity Package

Setup

  • Unity 2020.3.1f1 (Works with older versions as well)
  • Precompiled servers an in ServerWindows, run the bat you want to test
  • Open Samples/EchoClient/Scenes/NetworkExampleClient.unity and hit play.
  • Default port is 3333 when running the bat files.

Troubleshooting

  • I can't find the samples
    • The samples are stored in Assets/NetCoreNetworking/Samples~. A symlink at Assets/Samples points to the folder. That symlink might break when pulling for the first time on Windows. There are two solutions for it:
  • The precompiled server scripts don't work

TODO

  • Split messages back into the sent chunks
  • Fix bug: Repeated asnyc sending results in some packages not being sent for UDP
  • Support Websockets

Libraries

License

unity-net-core-networking-sockets's People

Contributors

johannesdeml avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-net-core-networking-sockets's Issues

Project not working correctly

Hey started the program on Unity and it worked. However, it never changes when I press send. Do you know what might be the Problem there? It is trying to connect to TCP, but seldomly connects. Adding to that I also cannot rarely press the send button. Any help will be appreciated.

Called SendAsync() multiple times but it sends string in one giant buffer

Hello, I am using your api to build my own network, really good job first of all.

The question is whenever I call SendAsync() multiple times in a function. The code seems to put them all in one buffer as a whole and send it, instead of sending individual buffer at a time. What happens is when my terminal receive an incoming buffer, it tries to parse it and understand the string. So sending it as one giant buffer really causes problem. Without digging too much into the code, it would be great if you could provide some simple solutions! thanks

Question about socket error

Hi,
I know this isn't actually directly related to this repo, but I thought I might ask it here as you have forked NetCoreServer for use inside of Unity and therefore might have a clue about following error. 🙂

I am trying to use TCP Server functionality from NetCoreServer iside of Unity and everything seems to work fine except one little problem. When I compile for iOS or Android using IL2CPP and exit application with some established connection, I can't seem to afterwards reopen it and start the server without this error:
SocketException: Address already in use

When I wait about 30 seconds and try to restart the server, it works without any problem. I guess the socket somehow stays binded after closing the application - even though I explicitly use server.Close() before application exit.

Please have you by any chance encountered similar behavior? When I disconnect the client before closing the application, restarting works just fine. However it is kind of unfortunate to get blocked for some time in case I forget to disconnect the client before closing. Thanks for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.