Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using jabber.client;
- using jabber.protocol.client;
- //using LitJson;
- public class xmpp : MonoBehaviour {
- // Use this for initialization
- void Start () {
- StartCoroutine("sendShit");
- }
- // Update is called once per frame
- void Update () {
- }
- IEnumerator sendShit()
- {
- JabberClient jc = new JabberClient();
- jc.User = "tester"; // just the username, not including the @domain.
- jc.Server = "ubuntu";
- jc.Password = "arne";
- jc.NetworkHost = "192.168.2.132";
- jc.Port = 5222;
- jc.Resource = "Jabber.Net Console Client";
- // don't do extra stuff, please.
- jc.AutoStartTLS = false;
- jc.PlaintextAuth = true;
- jc.RequiresSASL = true;
- jc.SSL = false;
- jc.AutoPresence = true;
- jc.AutoRoster = false;
- jc.AutoReconnect = -1;
- jc.Connect();
- // listen for errors. Always do this!
- jc.OnError += new bedrock.ExceptionHandler(j_OnError);
- // what to do when login completes
- jc.OnAuthenticate += new bedrock.ObjectHandler(j_OnAuthenticate);
- // message received
- jc.OnMessage += new MessageHandler(jc_OnMessage);
- //jc.Close();
- Debug.Log("test");
- yield return 0;
- }
- static void j_OnError(object sender, System.Exception ex)
- {
- Debug.Log("errroer");
- // There was an error!
- Debug.Log("Error: " + ex.ToString());
- // Shut down.
- //done.Set();
- }
- static void j_OnAuthenticate(object sender)
- {
- Debug.Log("we are sending");
- // Sender is always the JabberClient.
- JabberClient j = (JabberClient)sender;
- j.Message("kayoone@ubuntu", "test");
- // Finished sending. Shut down.
- //done.Set();
- }
- private void jc_OnMessage(object sender, Message msg)
- {
- //Debug.Log("RECV: " + msg.GetAttribute("body"));
- Debug.Log("RECV => ABSENDER: " + msg.From + " Nachricht: "+msg.Body);
- //JsonData json = JsonMapper.ToObject(msg.Body);
- //Debug.Log(json["unter"][0]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement