Search Unity

DarkRift - Fast and Flexible Cross Platform Networking

Discussion in 'Assets and Asset Store' started by Jamster, Apr 20, 2015.

  1. MOLITHAL

    MOLITHAL

    Joined:
    Aug 22, 2016
    Posts:
    26
    Yes i'm sending one array of strings, do you think that could be causing issues?

    Sending data over with the help of JaySON is working and luckily we only need to send that data once at the beginning of a match, so for now all is good and i can continue working on the game. The issue persists with the newer build you sent me but hopefully that main issue is fixed.
     
  2. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Interesting, I'll check it out for you :)
     
  3. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    The latest DarkRift packages have been accepted onto the Asset Store!
     
  4. MOLITHAL

    MOLITHAL

    Joined:
    Aug 22, 2016
    Posts:
    26
    Help me jebus!
     

    Attached Files:

  5. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    You're trying to serialize a DarkRiftReader which doesn't make sense, you should serialize DarkRiftWriters and deserialize to DarkRiftReaders.

    It's not always obvious where this is in code, I suspect you're Decoding the data in a message to a DarkRiftReader but then never swap that out for a writer, therefore it sees that the data field is not null and tries to serialize the Reader!
     
  6. MOLITHAL

    MOLITHAL

    Joined:
    Aug 22, 2016
    Posts:
    26

    public TournamentUserSmallData? DeserialiseTournamentSmallUserData(object data)

    {
    if (data is DarkRiftReader)
    {
    TournamentUserSmallData userNetData;
    using (DarkRiftReader reader = (DarkRiftReader)data)
    {
    userNetData._id = reader.ReadString();
    userNetData._stage = reader.ReadUInt16();
    userNetData._game = reader.ReadUInt16();
    return userNetData;
    }
    }
    else return null;
    }

    Here's the code i suspect is causing the issue. What to do?

    EDIT: I added
    reader.Close();
    reader.Dispose();
    just before it returns userNetData. Still no go.
     
    Last edited: Oct 25, 2016
  7. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    It wont be that they're not closed, it will be that it's a DarkRiftReader. You need to, at some point before your event handler, convert it to a DarkRiftWriter. Whether you do this manually or using DarkRiftUtilities doesn't matter.
     
  8. MOLITHAL

    MOLITHAL

    Joined:
    Aug 22, 2016
    Posts:
    26
    You're going to have to hold my hand here. I've tried 'DarkRiftUtilities.ConvertReaderToWriter(reader); ' first thing after i've declared the reader and the last thing before i return it, still didn't work. Where/how do i do this?
     
  9. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    As an example (I've not tested it so it might not compile)
    Code (csharp):
    1.  
    2. void OnDataReceived(ConnectionService con, ref NetworkMessage msg)
    3. {
    4.     DoStuff();
    5.  
    6.     if (msg.data is DarkRiftReader)
    7.         msg.data = DarkRiftUtilities.ConvertReaderToWriter((DarkRiftReader)msg.data);
    8. }
    You're basically doing a last check for anything leaving a reader.
     
  10. MOLITHAL

    MOLITHAL

    Joined:
    Aug 22, 2016
    Posts:
    26
    Hmm, now i'm getting a null reference exception.

    Code (csharp):
    1.  
    2. case TagIndex.ControllerSubjects.UserScored:
    3.  
    4.    msg.DecodeData();
    5.  
    6.    GameHandlerInstance.UpdateTournamentScore(con.id, Tournament.instance.DeserialiseTournamentSmallUserData(msg.data));
    7.  
    8. //The DeserialiseTournamentSmallUserData function is where the DR Reader is used and returns a struct
    9.  
    10.    if (msg.data is DarkRiftReader)
    11.       msg.data = DarkRiftUtilities.ConvertReaderToWriter((DarkRiftReader)msg.data);
    12. break;
    13.  
    (BTW thanks for all this help :D )
     

    Attached Files:

  11. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Which line...? o_O
     
  12. MOLITHAL

    MOLITHAL

    Joined:
    Aug 22, 2016
    Posts:
    26
    The main line
    Code (csharp):
    1.  
    2. msg.data = DarkRiftUtilities.ConvertReaderToWriter((DarkRiftReader)msg.data);
    3.  
     
  13. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Oh sorry, I misread your stacktrace!

    That is very odd, it would only throw a NullReferenceException if you passed in null, which you can't be doing because you're verifying it's a DarkRiftReader in the if statement :confused: Perhaps send me the file in a PM and I'll take a closer look for you.

    That is very strange behaviour!
     
  14. Vytek

    Vytek

    Joined:
    Apr 29, 2016
    Posts:
    50
    Hello @Jamster,
    as I promise I am studing your superb network library.
    I would like to creare a Metaverse ;-) but I am only a noob.

    I have created this project to test with awesome Gizmo Unity Script. It is very very stub, but I think very useful.

    What do you think about? Is it possible to enable only my object to move/rotate/scale?
    https://github.com/Vytek/MayaVerse

    Open DemoMainSceneWithGizmoAndDarkRift.unity in DarkRift/PlayerDemo dir

    Please let me know.
    Regards and thank you!
     
    Last edited: Oct 29, 2016
  15. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Hi Vytek,

    Sorry about the slow reply. I'm not entirely sure what you mean, do you mean make it so that only the player spawned by that player can be changed? That shouldn't be too hard at all, simply store which objects belong to which player on the server and then validate the packets as they come through from onDataRecevied :)

    Jamie
     
    Vytek likes this.
  16. RichardM

    RichardM

    Joined:
    Apr 4, 2013
    Posts:
    50
    @Jamster

    Hi Jamie,

    I am working on adding some additional logging for my server I want to record the user's ip address at login. Where can I get it from? I know it is there because I see the ip when they connect.

    Thanks in advance

    Richard M.
     
  17. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    ConnectionService.remoteEndPoint :) You will need to check and cast it to an IPEndPoint first though.
     
  18. RichardM

    RichardM

    Joined:
    Apr 4, 2013
    Posts:
    50
    @Jamster
    Ok I got that working... thanks for that. But I have a new glitch.

    In method (? never was clear on what is what. It has the same name as the class) I have:
    Code (CSharp):
    1.         public ServerCommands (){
    2.             ConnectionService.onData += OnDataReceived;
    3.             DarkRiftAPI.onPlayerDisconnected += PlayerDisconnected;
    4.        }
    Here is my "uncleaned code" (I get it working ten make it pretty) for the function (? see above .. ):
    Code (CSharp):
    1.         void PlayerDisconnected(ushort ID){
    2.             //set the online flag in the TempObjects to false
    3.             Interface.Log("this is it Player disconnected ID = " + ID);
    4.             //find uers account guid
    5.             string Query = "select AccountGUID from usersTable where IPAddress = '" + ID + "'";
    6.             /*if (ShowData == true)*/  Interface.Log("Account lookup = "+Query);
    7.             DatabaseRow[] ResultsAccount = DarkRiftServer.database.ExecuteQuery(Query);
    8.             string tempString = (ResultsAccount[0]["AccountGUID"]).ToString();
    9.  
    10.             //use account guid to get the character guids
    11.             Query = "SELECT CharacterGUID FROM toonTable where accountguid = '" + tempString + "';";
    12.             /*if (ShowData == true)*/ Interface.Log("ActiveUsers = " + Query);
    13.             DatabaseRow[] ResultsCharacter = DarkRiftServer.database.ExecuteQuery(Query);
    14.  
    15.             //switch user from active = true to =false in tempobjects
    16.             for (int i = 0; i < ResultsCharacter.Length; i++){
    17.                 Query = "UPDATE spaceObjects SET Online = '0' WHERE GUID = '" + (ResultsCharacter[i]["CharacterGUID"]).ToString() + "';";
    18.                 /*if (ShowData == true)*/ Interface.Log("ActiveUsers = " + Query);
    19.                 DarkRiftServer.database.ExecuteQuery(Query);
    20.             }//end for i
    21.  
    22.             //delete account from active users
    23.             Query = "DELETE FROM usersTable WHERE IPAddress = '"+ID+"';";
    24.             /*if (ShowData == true)*/ Interface.Log("ActiveUsers = " + Query);
    25.             DarkRiftServer.database.ExecuteQuery(Query);
    26.  
    27.         }//end of player disconnected
    28.  
    When the Player/User/Account disconnects I see:
    Obviously the port changes my ip doesn't. However when I added the "this is it" (line 3) to the code it isn't showing up in the console/log. What did I miss?


    Thanks in advance
    Richard M.
     
  19. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    You're mixing your client and server classes!

    DarkRiftAPI will only exist on the client, the server has nothing to do with DarkRiftAPI.
    ConnectionService is only on the server, the client has no clue what that is :)

    As this is on the server you shouldn't useany of the client classes.
     
  20. RichardM

    RichardM

    Joined:
    Apr 4, 2013
    Posts:
    50
    @Jamster
    OK ... removed DarkriftAPI from all my plugins ...

    It is always the little things that I trip over.

    Everything is working as it should now.

    Thanks for the assist ...again.

    Richard M.
     
  21. Finnark

    Finnark

    Joined:
    Feb 21, 2014
    Posts:
    8
    Hi Jamster, i just started using Darkrift 2 days ago and i have 2 questions so far:

    1) Is there a documentation on storing data on the server? id like to try storing login data and player customization options on the server so that the clients cannot "cheat" the game. ive been looking for the documentation but either im blind, im missing a file, or its just simply not there.

    2) I tried to create a shortcut to open a darkrift server from unity (cause its a pain to go through the explorer every time) like this:

    but after i open the exe through unity, the console says:
    this only happens when i try to open darkrift exe through unity and not when i double click on the exe. any reasons why this may happen? (and yes, correctly is misspelled though its not really a big deal ;) )

    Thanks in advance!
     
  22. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    I hope you're not using DarkRift 2, it's not out yet ;)

    Usually you'd use a database to store stuff like that, have a look at the MySQL connector :)

    I'm not sure about the code you're using but wherever the server is being run from (i.e. the directory it thinks it's in) doesn't contain the settings file.

    Jamie
     
  23. Finnark

    Finnark

    Joined:
    Feb 21, 2014
    Posts:
    8
    Thanks! i got the shortcut to work properly by changing the working directory!
    Ill look into the database stuff right now! pretty new to this!
    Also, its (I just started using Darkrift) (2 days ago) meaning todays my 3rd day of using Darkrift! (though id love to time travel to the age of Darkrift 2 ;) )
     
    Jamster likes this.
  24. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,486
    Hi,
    Just wanted to try it out. I am a super networking Newb, but get an error, on the EmbeddedCubeDemo. SocketException: No host in known.


    Also is this, your asset just a Network service? Would I still use Unity NetworkTransforms ect on a game level?


    Thanks


    PS. if this is just a network service, is there a cost, per game played etc, that is paid to you? How does that work?
     
  25. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Interesting error, do you have the embedded server running? Have you changed the default settings in any way?

    The asset completely replaces Unity's networking so you wouldn't use that no, you'd use DarkRiftAPI etc. on the client side and other classes (e.g. ConnectionService) on the server side.

    The cost is one off :)

    Jamie
     
  26. Finnark

    Finnark

    Joined:
    Feb 21, 2014
    Posts:
    8
    Hi its me again! Ive been trying to use DarkRift for my game and i have a new set of questions:
    1) Is it not possible to send custom classes to the server? I tried this:
    Code (CSharp):
    1.  
    2. DarkRiftAPI.SendMessageToServer(0, 0, new LoginDat("username", "password")); //1
    3. DarkRiftAPI.SendMessageToServer(0, 0, "abcdefg"); //2
    4.  
    I also have this code as a server plugin:
    Code (CSharp):
    1. public class DarkRiftPlugin : Plugin{
    2.     // Ill skip all the override stuff for this since they have no effect on the code atm
    3.     public DarkRiftPlugin(){
    4.         ConnectionService.onServerMessage += OnLoginRequest;
    5.     }
    6.  
    7.     public void OnLoginRequest(ConnectionService con, NetworkMessage msg){
    8.         Interface.Log("Received");
    9.         Interface.Log("data: " + msg.data.ToString());
    10.     }
    11. }
    #2 works properly when i run it but when i run #1 (with #2 commented out), not even the "Received" text appear on the console. does DarkRift refuse to send messages that have custom classes or is there some other problem going on here? Is there a way to send multiple set of data on a single message? or better yet, send data like fbx files onto a server? (just asking cause if there is a way to send user-made models to the server and store it for ppl to use like a mod, itll be awesome)

    2) on your FAQ page, you wrote that you suggest Microsoft Azure for a server. Is there a reason for that? What would be a possible problem if i try to use lets say, raspi 3 with darkrift server running on raspbian (along mono) instead? Would there be possible problems when i switch from one to the other halfway trough the project?

    3) I tried the above thing: using raspi 3 with raspbian and mono as a server for darkrift, and it produced some sort of missing file error when i tried to connect to the server from a unity instance on my windows 10 pc. i dont remember what the error was but ill post the error on my next reply when i get back to my house.

    Thanks in advance!
     
  27. Finnark

    Finnark

    Joined:
    Feb 21, 2014
    Posts:
    8
    Ok heres the screenshot of the darkrift server on raspi 3 running raspbian. can you tell me if theres a way to fix this problem?
    https://i.imgsafe.org/ca0abc5e23.png

    Thanks again! :D
     
  28. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Hey!

    It is possible, verify that your class has a [Serializable] attribute because otherwise DarkRift can't convert it to bytes to send. Even better use a DarkRiftWriter and Reader to serialize it (that's the recommended way and will make upgrading to DarkRift 2 easier).

    N.B. The reason you don't get any errors explaining why is because serialization happens in a different thread so it's very hard to feed them back to Unity.

    I suggest Azure because that's what I use, there's also a chance that DarkRift 2 will have better integration with Azure in the future (maybe).

    You can use a Raspberry Pi but you will get very poor performance (because its a Raspberry Pi). I've used them for testing and they do work for basic development. It seems like your mono is missing certain libraries so perhaps try and run apt-get -update mono-complete (I think it's that, I don't do much Linux). You shouldn't have any problem switching hosts at any point.
     
    Finnark likes this.
  29. supreem_creator

    supreem_creator

    Joined:
    Jan 14, 2014
    Posts:
    10
    I apologize if this has already been answered but I could not find it.

    I have multiple server processes that run out of the same directory. They fight for the log files which throws an exception. Is it possible to reroute the file log output to my own logging system? Or can I configure the log path for each process so they are different?
     
  30. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Not in DarkRift 1 unfortunately, you can in DarkRift 2 when it comes out. If you can start them at different times, at least 1 second apart they should all generate different logfiles if that helps?
     
  31. Finnark

    Finnark

    Joined:
    Feb 21, 2014
    Posts:
    8
    Hi. Its me again! (for like the third time)

    This isnt really a question or anything so i wasnt sure whether to post it here, but I found a error while using DarkRift on a linux system as well as how to solve it so i thought might as well share it.

    https://forum.unity3d.com/threads/d...nux-machines-errors-and-how-to-fix-it.444328/

    Sorry if this problem was already known and solved or if ive been doing something the wrong way the entire time. I havent been able to check if anybody has ever run into this issue before.
     
    Jamster likes this.
  32. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Yeah I should probably be using Path.Combine instead of that backslash there... Good work!
     
  33. Finnark

    Finnark

    Joined:
    Feb 21, 2014
    Posts:
    8
    Thanks! Hopefully it may help out other developers as well! :D also:
    You may have noticed from the console img that Ive been making quite a few plugins, notably the DRDataBase and DRLobby which I made mainly for my game but i tried to make it as generic as possible just in case i feel like it may benefit others if i post it somewhere. However, i also know that darkrift 2 is coming up soon and i believe both plugins will be obsolete once it comes out.
    Question is: any estimated guesses on when darkrift 2 will come out? cause if its coming out in lets say, january~march 2017, i might as well wait on continuing with the plugin stuff and focus on making my game instead! ;)
     
  34. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Well I keep having to delay it, at the start it was supposed to be June but that went and passed a while ago! I guess at the moment I would say February beta. Maybe. Ish. :oops:
     
  35. Finnark

    Finnark

    Joined:
    Feb 21, 2014
    Posts:
    8
    Alright. Thanks! Looking forward to it! XD
     
  36. cabbyU

    cabbyU

    Joined:
    Sep 21, 2016
    Posts:
    11
    I'm using DarkRift to write an authoritative server and I'm having an issue where the clients can send messages to the server just fine, but most messages from the server do not reach the client. In one scenario, I found that the client did not receive a message a containing a custom serializable struct, but did receive a message containing a simple string.

    Server Code:

    //client never gets this. onDataDetailed callback never gets called
    pConnectionService.SendReply (Tags.PluginRequest, pSubject, new ServerResponse(pData));

    //client does get this
    pConnectionService.SendReply ((byte)3, pSubject, "TEST");

    ServerResponse is a struct marked as [Serializable]. I thought maybe there was a problem with the serialization of this object, but I only started experiencing this problem when I switched to using a remote server instead of running the server from my local machine. When I run the clients and server all on the same machine I don't have this issue. Any ideas what might be going on? I am not getting any errors on either the client or server.
     
  37. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Hi cabby,

    It's a known problem, basically something is going wrong with the serialization but because DarkRift does all that in separate threads you don't see the exception come out!

    I've just put in a fix to DarkRift and I'll try and release it at some point soon.

    For now it would be better to upgrade your code to use DarkRiftWriter/DarkRiftReader for the serialization, you'll also see performance benefits and it'll be more easy to transfer to DarkRift 2!

    Jamie
     
  38. elamdaly

    elamdaly

    Joined:
    Jul 19, 2016
    Posts:
    4
    Hello,

    We're using Darkrift to pass messages between a tablet and server for an interactive application. I have a custom class tagged with the [Serializable] attribute, and it's carrying a byte[] which is populated with a tex.EncodeToJPG(); call.

    When I send the payload via DarkRiftAPI.SendMessageToID(), it crashes the Darkrift server with an exception. I'm not sure how to proceed, but I'm assuming I'd need to use a DarkriftReader/Writer for this? The byte[]'s are around 70-100 kilobytes.

    Code (csharp):
    1.  
    2. Unhandled Exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    3. Parameter name: size
    4.    at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode, AsyncCallback callback, Object state)
    5.    at System.Net.Sockets.Socket.BeginReceive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
    6.    at DarkRift.ConnectionService.StartWaitingForChunk(StateObject state)
    7.    at DarkRift.ConnectionService.ChunkReadCallback(IAsyncResult result)
    8.    at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
    9.    at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    10.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    11.    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    12.    at System.Net.ContextAwareResult.Complete(IntPtr userToken)
    13.    at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
    14.    at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
    15.    at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
    16.  
     
  39. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    I think this is a bug that is fixed for the next release... It's nearly ready but there are still one or two issues that need to be resolved before I can release it. PM me and I can send the latest package but can't guarantee it's not bug free.
     
  40. elamdaly

    elamdaly

    Joined:
    Jul 19, 2016
    Posts:
    4
    PM sent. Thanks!
     
  41. RichardM

    RichardM

    Joined:
    Apr 4, 2013
    Posts:
    50
    Hi All,

    I have a weird one. I have a plugin that creates really basic missions for players. All this is doing is grabbing 3 random variables to build a sentence.

    When I run it without sending info to the console the results (accept for the GUID) are the same. However if I send results to the console everything works perfectly. It makes no sense to me. Here is the code that is causing me grief.

    Code (CSharp):
    1.         public void OnDataReceived(ConnectionService con, ref NetworkMessage msg){
    2.             if (msg.tag == 3){
    3.                 msg.DecodeData();
    4.                 if (msg.subject == 120){
    5.                     if (logMission == true) { Interface.Log("tag = 3, Message = 120 , data = " + msg.data.ToString());}
    6.                     string missionInfo = msg.data.ToString();
    7.                     string missionType = missionInfo.Substring(0, 1);
    8.                     string missionOwner = missionInfo.Substring(2);
    9.                     if (missionType == "0"){
    10.                         for (int i = 0; i < 5; i++){
    11.                             string missionName = "";
    12.                             int subType1 = randomNumber(1, 1000);
    13.                             if ((logMission == true) ) { Interface.Log("SubType1 = " + subType1); }
    14.                             int subType2 = 0;
    15.                             if (subType1 <= 500){
    16.                                 missionName = "Eliminate";
    17.                                 subType2 = randomNumber(1, 1000);
    18.                             }else {//end if subType1 < 500
    19.                                 missionName = "Capture";
    20.                                 subType2 = 0;
    21.                             }//end if subType1 = 0 else
    22.                             if ((logMission == true) ) { Interface.Log("SubType2 = " + subType2); }
    23.                             if (subType2 <= 500){
    24.                                 missionName += " Description Goes Here";
    25.                             }else {//end of subtype2 < 500
    26.                                 missionName += " Description Goes Here 2";
    27.                             }//end of subtype2 = 0 else
    28.  
    29.                             int subType3 = randomNumber(0, 7);
    30.                             if ((logMission == true) ) { Interface.Log("SubType3 = " + subType3); }
    31.                             if (subType3 == 0) { missionName += " Type1."; }
    32.                             if (subType3 == 1) { missionName += " Type2."; }
    33.                             if (subType3 == 2) { missionName += " Type3."; }
    34.                             if (subType3 == 3) { missionName += " Type4."; }
    35.                             if (subType3 == 4) { missionName += " Type5."; }
    36.                             if (subType3 == 5) { missionName += " Type6."; }
    37.                             if (subType3 == 6) { missionName += " Type7."; }
    38.  
    39.                             int reward = randomNumber(1000, 2000);
    40.                             if (subType1 > 500){ reward = reward * 2; }
    41.                             //generate guid
    42.                             string missionGUID = Guid.NewGuid().ToString();
    43.                             string Query = "insert into gro.missionlisttable(MissionGUID,CharacterGUID, MissionName, MissionReward) values ('" + missionGUID + "','" + missionOwner + "','" + missionName + "','" + reward + "');";
    44.                             if ((logMission == true) ){Interface.Log("MM 3,120 - " + Query);}
    45.                             DarkRiftServer.database.ExecuteQuery(Query);
    46.                             string ReplyMessage = missionGUID + "," + missionName + "," + reward;
    47.                             con.SendReply(3, 121, ReplyMessage);
    48.                         }//end of for i loop
    49.                     }//end mission type = 0
    50.                 }//end if subject = 120
    51.  
    52.             }//end of tag = 3
    53.         }//end of OnDataReceived
    54.  
    55.         static int randomNumber (int min, int max){
    56.             Random randomValue = new Random();
    57.             return randomValue.Next(min, max);
    58.         }//end static int
    59.  
    I cut out the code that is not applicable, and I have a lot of other work to do to finish this. I just can't figure out why when "logMission = true" it works correctly but not when it's false.

    Any thoughts?

    Richard M.
     
  42. Vorlian

    Vorlian

    Joined:
    Nov 30, 2016
    Posts:
    3
    Anyone know how to fix this?
    trying to build the client.
     
  43. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    @RichardM try taking the Random object out the function and making it either a static or a member variable. They're seeded from the clock so if you generate them in quick succession they result in the same seed and the same random numbers. My guess is that as GUI operations are costly enough that it takes just enough time to push the random generators to different seeds when you log.

    @Vorlian I suspect you have extracted the server folder into that same directory as your Unity project, because they both contain Transmission.dll you get a conflict! Try extracting it on your desktop (example) instead :)
     
  44. elamdaly

    elamdaly

    Joined:
    Jul 19, 2016
    Posts:
    4
    Hi Jamster,

    I'm using the beta and I can send image byte[]'s , but sometimes the connection of the client receiving the image is dropped with this:
    Code (csharp):
    1.  
    2. Disconnect was due to handled exception: System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
    3.    at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
    4.    at DarkRift.ConnectionService.ChunkReadCallback(IAsyncResult result)
    I know it's a beta! Is there a way to notify the sender that the message wasn't sent and they should try again?
     
  45. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    That error is indicating they are no longer connected to the server so no, without reconnecting there isn't :(
     
  46. elamdaly

    elamdaly

    Joined:
    Jul 19, 2016
    Posts:
    4
    Hi Jamster,

    The receiver client was disconnected, not the sender, so I was just wondering if it's possible to catch the server side exception on the client sender side. I'm assuming not because of async issues!

    I was initially passing 1920x1080 images at a little over 100K, coming from a webcam. I've since dropped it to 1280x720 with much greater success.
     
  47. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    That's my fault, fixed a bug on one the server side but forgot to fix it on the client side as well!
     
  48. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    643
    Quick question. If I embed my server in Unity (in order to use physics), will the instance of Unity running (as the server) receive messages from the SendToServer method? ...if so, how?
     
  49. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,042
    Yes, it's exactly the same API so anything you get with standalone servers can be done in embedded servers :) Essentially it's just running under Unity rather than a console window :)
     
  50. DRRosen3

    DRRosen3

    Joined:
    Jan 30, 2014
    Posts:
    643
    Okay. Awesome. Also, I was looking into the EmbeddedServer Demo and I'm somewhat confused by the SendReply method. What's the difference from using ConnectionService.SendReply, and using DarkRiftAPI.SendMessageToID? In particular I'm wondering what (if any) difference would there be between...

    Code (CSharp):
    1.     void Update()
    2.     {
    3.         //Broadcast all positions to all clients constantly
    4.         foreach (ConnectionService cs in DarkRiftServer.GetAllConnections())
    5.         {
    6.             for (int i=0; i<cubes.Length; i++)
    7.             {
    8.                 cs.SendReply(0, (ushort)i, (Vector3Carrier)cubes[i].position);
    9.             }
    10.         }
    11.     }
    ...and...

    Code (CSharp):
    1.     void Update()
    2.     {
    3.         //Broadcast all positions to all clients constantly
    4.        for (int i=0; i<cubes.Length; i++)
    5.        {
    6.            DarkRiftAPI.SendMessageToOthers(0, (ushort)i, (Vector3Carrier)cubes[i].position);
    7.        }
    8.     }
     
unityunity