I am getting SocketException: Could not resolve host ‘irc.chat.twitch.tv’
You can check here
http://blueicegame.com/test/
My connect code is
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.ComponentModel;
using System.Net.Sockets;
using System.IO;
using UnityEngine.UI;
public class TwitchChat : MonoBehaviour {
private int port = 6667;
private string server = "irc.twitch.tv";
private TcpClient twitchClient;
private StreamReader reader;
private StreamWriter writer;
public string username, password, channelName; // Get password from https://twitchapps.com/tmi
public Text chatBox;
// Use this for initialization
void Start() {
Connect();
}
// Update is called once per frame
void Update() {
if (!twitchClient.Connected)
{
Connect();
}
ReadChat();
}
private void Connect()
{
System.Net.Sockets.TcpClient twitchClient = new System.Net.Sockets.TcpClient();
twitchClient.Connect(server, port);
reader = new StreamReader(twitchClient.GetStream());
writer = new StreamWriter(twitchClient.GetStream());
writer.WriteLine("PASS " + password);
writer.WriteLine("NICK " + username);
writer.WriteLine("USER " + username + " 8 * :" + username);
writer.WriteLine("JOIN #" + channelName);
writer.Flush();
}
private void ReadChat()
{
if (twitchClient.Available > 0)
{
var message = reader.ReadLine(); // Read Current Message
if (message.Contains("PRIVMSG"))
{
// Get users name by splitting it from string
var splintPoint = message.IndexOf("!", 1);
var chatName = message.Substring(0, splintPoint);
chatName = chatName.Substring(1);
// Get users message by splitting it from string
splintPoint = message.IndexOf(":", 1);
message = message.Substring(splintPoint + 1);
//print(String.Format("{0}: {1}", chatName, message));
chatBox.text = chatBox.text + "\n" + String.Format("{0}: {1}", chatName, message);
//Run the instructions to control the game!
}
}
}
}