Search Unity

please remove

Discussion in 'Multiplayer' started by vriog, Feb 17, 2017.

  1. vriog

    vriog

    Joined:
    Dec 6, 2014
    Posts:
    32
    I have a custom game server I wrote in Node.js and want to write a C# Unity client for it. I am using websockets to transfer the data and have already made a pure web client for it in Javascript. I found the third party library websockets-sharp which I made a prototype client with, but it seems to have problems with threading which creates minor (but frustrating) lag, so I am wondering if I could use UNET to write the client instead.
     
    Last edited: Feb 17, 2017
  2. mofirouz

    mofirouz

    Joined:
    Jul 14, 2015
    Posts:
    27
  3. or113

    or113

    Joined:
    Nov 5, 2016
    Posts:
    41
    Could you please tell us a bit more about the game? It's really different if that a fps or turn based game.
     
  4. TheUKDude

    TheUKDude

    Joined:
    Jul 27, 2013
    Posts:
    72
    Also when you say its using WebSockets is that for HTTP(s) Requests or are you referring to using TCP or UDP Socket connections?

    The lag that your referring to could be where its not multi threaded and when its receives data that needs to be processed it goes off to do that which might take a little while to complete and where its single threaded everything else has to wait until its completed what it doing, that would cause delays.

    Like or113 has already stated, it all depends of the type of game, like a turn based game could work using HTTP(s) requests and responses where as FPS would have issues and would require UDP or TCP socket communication.

    I myself am using the LLAPI (NetworkTransport) which used UDP which seems to be going well so far.

    Paul
     
    joaoborks likes this.
  5. TheUKDude

    TheUKDude

    Joined:
    Jul 27, 2013
    Posts:
    72
    I ended up writing my own TCP Server Library designed specifically for my game which uses Threads, Queues etc and I am about 72% complete for the server side.

    Paul
     
  6. Kirkja

    Kirkja

    Joined:
    Oct 18, 2009
    Posts:
    7
    Paul, I'm curious how your TCP Server Library has worked out?
     
  7. TheUKDude

    TheUKDude

    Joined:
    Jul 27, 2013
    Posts:
    72
    Sorry for the delay in the reply, erm well I am still adding stuff to it, its more custom written for my games that I am currently working on and my future ones.

    My Networking Library is written externally from Unity so that I can create a dedicated server that can be written away from Unity and at the same time have the Client side of things written in Unity.

    Due to current health issues I had to stop work on my library, but I am starting to come back to work on it.

    There is nothing special about my library, I am just using TcpListener / Sockets for the Server and TcpClient / Socket for the client.
    I am also thinking of adding support for UDP and WebRequest to the library, but this will probably be later on.

    Also both sides of the networking (Client and Server) i.e. the network loop are Threaded by one or more threads (Primary and Support Threads) which is configurable depending on the type of game, this might also be an automated feature later on.

    I also use multiple threads for the message queues like for reading and writing of network messages etc.

    I have also created my own ThreadManager based around System.Threading.Thread which allows me to easily create, start, stop and remove threads on the fly.

    The hard part was when I added the Threading stuff where it broke my current code lol.

    Paul