Search Unity

WebGL Networking help!

Discussion in 'WebGL' started by aodonn, Sep 12, 2019 at 2:06 AM.

  1. aodonn

    aodonn

    Joined:
    Aug 20, 2015
    Posts:
    3
    Hi there, I'm wondering how I can get connections using direct socket access to work with a webGL build. Below is the code I'm trying to translate:

    Code (CSharp):
    1. private TcpClient twitchClient;
    2. private StreamReader reader;
    3. private StreamWriter writer;
    4.  
    5.     public void Connect()
    6.     {
    7.         twitchClient = new TcpClient("irc.chat.twitch.tv", 6667);
    8.  
    9.         reader = new StreamReader(twitchClient.GetStream());
    10.         writer = new StreamWriter(twitchClient.GetStream());
    11.  
    12.         writer.WriteLine("PASS " + password);
    13.         writer.WriteLine("NICK " + username);
    14.         writer.WriteLine("USER " + username + " 8 * :" + username);
    15.         writer.WriteLine("JOIN #" + channelName);
    16.         writer.Flush();
    17.     }
    18.  
    Since this method is not available for webGL builds I'm wondering how easy this is to convert to WWW or UnityWebRequest.

    I'm really not very experienced this this side of things so excuse me if I seem like I don't have a clue what I'm talking about (as I really don't!).

    I appreciate all and any help, thanks!