Search Unity

Client DLL in c++

Discussion in 'Multiplayer' started by matt77, May 4, 2009.

  1. matt77

    matt77

    Joined:
    Apr 14, 2009
    Posts:
    21
    Hi everyone,

    i'm coding a dll in c++ wich the client in unity will use to communicate with the server, external to unity and also built in c++.

    So i wanted some opinions and comments. Has anyone done this? Is it a good aproach?
     
  2. carbonization

    carbonization

    Joined:
    Mar 23, 2009
    Posts:
    37
    I don't see a reason not to script (They don't call it .Net for nothing). I've recently begun working on a C++ server also, and for that I'm just using Unity's RakNet distro. Because Unity's networking uses RakNet also messaging RPCs and state sychronization *should* already be taken care of by RakNet (I literally just started yesterday, but the Unity client has been successfully connecting to my server lol). The next task at hand that I see is parsing Unity's structures, specifically Vector3 Quaternion, which I can't imagine will be to terribly difficult. Once you get a stable communication between the two, then you're free to write the rest of the server however you need.

    As you can tell I still got my feelers out, so any tips/suggestions/corrections would be great.
     
  3. matt77

    matt77

    Joined:
    Apr 14, 2009
    Posts:
    21
    Thanks Carbonization.

    I took a little look at the raknet code some days ago, yet i didn't dip much in how it handles the messages.

    I was thinking of using Raknet server more like of a 'proxy server' relaying messages between the game server and the client, using also the nat facilitator.

    Have you done any reverse engineering in order to handle correctly unity's rpc and state sync in raknet?

    Any info on parsing unity's structures would be nice too.

    best regards!
     
  4. carbonization

    carbonization

    Joined:
    Mar 23, 2009
    Posts:
    37
    RakNet MessageIDs: 0-70

    From what I've found Unity added the MessageIDs:
    71: State update: NetworkViewID allocatedID
    72: Same as above
    73: Sent from server with PlayerID to complete successful client connection; OnConnected called clientside
    74: RemoveRPCs
    75: Sent by client, OnPlayerConnected called serverside (I think), response with MessageID 73 with an allocated PlayerID must be sent back before OnConnected called clientside
    80: Initialize relay service from a proxy (sent from proxy to client): uint proxyVersion, uint port
    200-202: Master server

    78 79 do something I think because the Unity client spit out "Unhandled relayed message 0" (0 a uint I think) instead of the standard "Unhandled message"

    As for RPCs state synchronization I'd assume it's the same as RakNet's.
     
  5. gabriel.santos

    gabriel.santos

    Joined:
    Mar 19, 2009
    Posts:
    53
    Hi Carbonization,

    Have you used the Network.Connect() to connecto to your Raknet implementation ? or have you Built SOckets to do that !!

    Because I am creating my own dedicated server and I started from scratch, so I am using Sockets to do the connection ..But this way I have to implement my own Networking on Client side as well (NetworkView, etc..), and I think this is gonna take a while...So I changed my mind and decided to implement a Raknet Based Server ...

    I have started to take a look at Raknet Code, but I still didnt figure out how it works exactaly ...

    So any information would be great!
    Best Regards !
    Thanks in advance !
     
  6. matt77

    matt77

    Joined:
    Apr 14, 2009
    Posts:
    21
    Gabriel, I have successfully connected to the RakNet server using the Network.Connect(), and also could connect as RakNet client to a unity server.

    If you have any progress further than what we already have here, please post them (I'm sure you'll do, since you have shared some combine mesh scripts on the wiki, ;))


    For now i'm having some issues trying to communicate with unity. My mates and i are moving slowly because, we don't know what unity expects as response. So we have to try step by step, both as client and server, to see how unity behaves. As for now, i ain't got nowhere beyond Carbonization (only got some already know ID's and the 75 ID).

    Any news, i'll post it.

    Thanx for all!

    EDIT: usefull info here: http://forum.unity3d.com/viewtopic.php?t=14704&highlight=networkview