1. Do you need support for Assetto Corsa Competizione? Please use the proper forum below and ALWAYS zip and attach the WHOLE "Logs" folder in your c:\users\*youruser*\AppData\Local\AC2\Saved. The "AppData" folder is hidden by default, check "Hidden items" in your Windows view properties. If you report a crash, ALWAYS zip and attach the WHOLE "Crashes" folder in the same directory.
  2. FOR ASSETTO CORSA COMPETIZIONE: If you report issues with saved games, please always zip and attach your entire User/Documents/Assetto Corsa Competizione/Savegame folder!
  3. If your game executable is missing, please add your entire Steam directory to the exceptions in your antivirus software, then run a Steam integrity check or reinstall the game altogether.

Let's talk about broadcasting (programmer's thread)

Discussion in 'ACC General Discussions' started by Minolin, Dec 12, 2018.

  1. Minolin

    Minolin Staff Member KS Dev Team

    Please have a look at the WriteString() method in the sample, you'll need an equivalent for both prefixing the size and converting to UTF8.
     
  2. leosntone

    leosntone Rookie

    Code:
    public static void writeByte(ByteArrayOutputStream os , String s) throws Exception{
            byte[] temp = s.getBytes("utf-8");
            os.write((short)temp.length);
            os.write(temp);
        }
    java no unsigned integer. only short is 2 byte but signed.
     
  3. Minolin

    Minolin Staff Member KS Dev Team

    If you are sure your value is > 0, you can pass the signed one.

    There are for sure correct bit shifting solutuions out there, but this makes me think of moving everything to int32. There are no big pakets anymore, size won't hurt
     
  4. leosntone

    leosntone Rookie

    REGISTER_COMMAND_APPLICATION = 1
    BROADCASTING_PROTOCOL_VERSION =2
    displayName = name
    connectionPassword=12345
    msRealtimeUpdateInterval=100
    commandPassword=12345

    byte[] = [1, 2, 4, 110, 97, 109, 101, 5, 49, 50, 51, 52, 53, 100, 5, 49, 50, 51, 52, 53]
     
  5. Minolin

    Minolin Staff Member KS Dev Team

    right.. it should be

    1, 2, 4, 0, 110, 97, 109, 101, 5, 0, 49, 50, 51, 52, 53, 100, 0, 0, 0, 5, 0, 49, 50, 51, 52, 53

    So for some reason your string size descriptor is 1 byte instead of a short (I absolutely don't see why).
    And the os.write(100); seems to write a byte instead of int32 as well. Given the surprising platform difficulties I'd like to add this is expected in little endian.
     
  6. leosntone

    leosntone Rookie

    thank you for reply me.

    java byte[] result is [1, 2, 4, 110, 97, 109, 101, 5, 49, 50, 51, 52, 53, 100, 5, 49, 50, 51, 52, 53]
    C# is 1,2,4,0,110,97,109,101,5,0,49,50,51,52,53,100,0,0,0,5,0,49,50,51,52,53,
    so
    Code:
    ByteArrayOutputStream os = new ByteArrayOutputStream();
            os.write((byte)1);
            os.write((byte)2);
            writeByte(os,"name");
            writeByte(os,"12345");
            os.write(100);
            os.write(0);
            os.write(0);
            os.write(0);
            writeByte(os,"12345");
            byte[] bytes = os.toByteArray();
    Code:
    public static void writeByte(ByteArrayOutputStream os , String s) throws Exception{
            byte[] temp = s.getBytes("utf-8");
            os.write((short)temp.length);
            os.write(0);
            os.write(temp);
        }
    it works. i can receive data. :p
     
  7. Minolin

    Minolin Staff Member KS Dev Team

    ya but that won't help much, I figure you'll see the same mismatches on the receiving side.
    *very* surprised about java here, in multiple perspectives
     
  8. leosntone

    leosntone Rookie

    just like, int16 is 2 byte, so br.write(ushort) needs two positions , it is [4, 0] if bw.Write(Convert.ToUInt16(bytes.Length));
    bw.Write(100), int32 is 4 byte, so it is [100,0,0,0] .
    Very strange. :p
     
  9. ZioYuri78

    ZioYuri78 Hardcore Simmer

    Finally i'm back to code, i figured out how to connect and receive data with UE4, the strange thing is that i can't get the "local" socket port until i send data at least once, i supposed that once you have created a socket you was ok on gather the port, btw the solution it's pretty easy and i get it after the first time i send data with the "request connection" like this:

    Code:
    .
    .
    SenderSocket->SendTo(Message.GetData(), Message.Num(), BytesSent, *RemoteAddr);
    
    SenderLocalPort = SenderSocket->GetPortNo();
    .
    .
    
    now i can start write all the structures and all the remaining stuff.
     
    TDS likes this.
  10. ZioYuri78

    ZioYuri78 Hardcore Simmer

    Now i can read and write strings (from FString to UTF8 and viceversa), now the road is all downhill (or at least until the next bug) :)
    Code Snippets below (class, variables and functions names are subject to change..maybe..) :

    Code:
    void AUDPSenderReceiver::WriteString(FArrayWriter &Buffer, const FString &String)
    {
        int16 SLength = String.Len();
        ANSICHAR *UTF8String = TCHAR_TO_UTF8(*String);
        
        Buffer << SLength;
        for (char *p = UTF8String; p < UTF8String + SLength; ++p)
        {
            Buffer << *p;
        }
    }
    
    Code:
    void AUDPSenderReceiver::ReadString(const FArrayReaderPtr &Buffer, FString &String)
    {
        int16 SLength = 0;
        uint8 SChar = 0;
    
        *Buffer << SLength;
    
        for (int i = 0; i < SLength; ++i)
        {
            *Buffer << SChar;
            String.AppendChar(SChar);
        }
    }
    
     
    TDS likes this.
  11. ZioYuri78

    ZioYuri78 Hardcore Simmer

    Hey @Minolin , which is the correct way to unregister/disconnect a client? I tried send a request with the UNREGISTER_COMMAND_APPLICATION and BROADCAST_PROTOCOL_VERSION like this (UE4 C++)
    Code:
    void AUDPSenderReceiver::ACCDRequestDisconnection()
    {
        FArrayWriter Message;
        uint8 CommandType = (uint8)EOutboundMessageTypes::UNREGISTER_COMMAND_APPLICATION;
        uint8 ProtocolVersion = (uint8)EBNProtocol::BROADCAST_PROTOCOL_VERSION;
    
        Message << CommandType;
        Message << ProtocolVersion;
    
        int32 BytesSent = 0;
        SenderSocket->SendTo(Message.GetData(), Message.Num(), BytesSent, *RemoteAddr);
    
        CheckByteSent(BytesSent);
    
    }
    
    but it doesn't work, maybe i need to also send the ConnectionId?
     
    TDS likes this.
  12. leosntone

    leosntone Rookie

    now it does not work at 0.6 ???
     
  13. sps_for_race

    sps_for_race Alien

    Check the changelog:
    https://www.assettocorsa.net/forum/index.php?threads/update-0-6-mp-ratings-rebooted.55050/


     
  14. leosntone

    leosntone Rookie

    now, 1.0 released. but when i connected game, it show this error massege "Your broadcasting control app is outdated".
    I use source code compilation which in release game.
     
  15. ZioYuri78

    ZioYuri78 Hardcore Simmer

    Yeah, is still the old client.
     
  16. leosntone

    leosntone Rookie

    but i use Testclient/ksBroadcastingTestClient.exe it works fine. o_O
     
  17. ZioYuri78

    ZioYuri78 Hardcore Simmer

    Maybe @Minolin uploaded the right compiled client but the old source code :D
     
  18. Minolin

    Minolin Staff Member KS Dev Team

    ya looks like that, sorry :-/ let me fish the first 200 tasks on my list and I'll try to upload the current sources
     
  19. Can someone provide an overview of the changes of the udp interface with the new update (1.1)?
     
  20. Minolin

    Minolin Staff Member KS Dev Team

    no changes, C# sample in the steam folder should be up to date
     
    Ensi Ferrum likes this.
Similar Threads
Forum Title Date
ACC General Discussions Let's talk about broadcasting (user's thread) Dec 12, 2018
Console Lounge Let's talk vote to kick Mar 18, 2017
Console Lounge Quick race weekend (let's talk abou it Vol.1) Feb 24, 2017
Chit Chat Room Let's talk Lotus 98T Feb 17, 2017
Console Lounge Porsche Cayman GT4 - Let's talk gearing Jan 16, 2017
Console Lounge Let's talk about rage quitters... Dec 9, 2016
Chit Chat Room 935/78 - Let's talk setup and driving Oct 30, 2016
Console Lounge Let's talk about braking Oct 6, 2016
Suggestions Let's talk weather (I am not asking for rain). Aug 15, 2016
Chit Chat Room Let's talk wheels...again. why not? Aug 27, 2014
ACC General Discussions Let's get acquainted? Nov 28, 2019
ACC General Discussions POLL! Let's buy this game again every year to support Assetto Corsa guys! Jul 20, 2019
ACC Screenshots & Videos Let's Play VR (Pimax 5K +) Porsche + Spa Francorhamps :) Jul 2, 2019
Suggestions Let's REQUEST CARS Here Jan 15, 2018
Chit Chat Room Ok guys (and girls) , let's proove AC right (or wrong) using Laguna Seca. Jan 2, 2018

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice