Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using jabber.client;
  4. using jabber.protocol.client;
  5. //using LitJson;
  6.  
  7. public class xmpp : MonoBehaviour {
  8.  
  9.     // Use this for initialization
  10.     void Start () {
  11.        
  12.         StartCoroutine("sendShit");
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update () {
  17.        
  18.     }
  19.    
  20.     IEnumerator sendShit()
  21.     {
  22.         JabberClient jc = new JabberClient();
  23.         jc.User = "tester";   // just the username, not including the @domain.
  24.         jc.Server = "ubuntu";
  25.         jc.Password = "arne";
  26.         jc.NetworkHost = "192.168.2.132";
  27.         jc.Port = 5222;
  28.         jc.Resource = "Jabber.Net Console Client";         
  29.         // don't do extra stuff, please.
  30.         jc.AutoStartTLS = false;
  31.         jc.PlaintextAuth = true;
  32.         jc.RequiresSASL = true;
  33.         jc.SSL = false;
  34.         jc.AutoPresence = true;
  35.         jc.AutoRoster = false;
  36.         jc.AutoReconnect = -1;
  37.         jc.Connect();
  38.        
  39.         // listen for errors.  Always do this!
  40.         jc.OnError += new bedrock.ExceptionHandler(j_OnError);
  41.  
  42.         // what to do when login completes
  43.         jc.OnAuthenticate += new bedrock.ObjectHandler(j_OnAuthenticate);
  44.        
  45.         // message received
  46.         jc.OnMessage += new MessageHandler(jc_OnMessage);
  47.  
  48.         //jc.Close();
  49.        
  50.         Debug.Log("test");
  51.        
  52.         yield return 0;
  53.     }
  54.    
  55.     static void j_OnError(object sender, System.Exception ex)
  56.     {
  57.         Debug.Log("errroer");
  58.         // There was an error!
  59.         Debug.Log("Error: " + ex.ToString());
  60.  
  61.         // Shut down.
  62.         //done.Set();
  63.     }
  64.    
  65.     static void j_OnAuthenticate(object sender)
  66.     {
  67.         Debug.Log("we are sending");
  68.         // Sender is always the JabberClient.
  69.         JabberClient j = (JabberClient)sender;
  70.         j.Message("kayoone@ubuntu", "test");
  71.  
  72.         // Finished sending.  Shut down.
  73.         //done.Set();
  74.     }
  75.    
  76.     private void jc_OnMessage(object sender, Message msg)
  77.     {
  78.         //Debug.Log("RECV:  " + msg.GetAttribute("body"));
  79.         Debug.Log("RECV => ABSENDER: " + msg.From + " Nachricht: "+msg.Body);
  80.         //JsonData json = JsonMapper.ToObject(msg.Body);
  81.         //Debug.Log(json["unter"][0]);
  82.     }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement