Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.91 KB | None | 0 0
  1. class Service(con:XMPPConnection, username:String, server:String)
  2. {
  3.     conn.connect;
  4.     conn.login(username, password);
  5.  
  6.     def this(username:String, server:String, password:String)
  7.     {
  8.         val conn = new XMPPConnection(server);
  9.         this(conn, username, password)
  10.     }
  11.  
  12.     def this(jid:String, password:String)
  13.     {
  14.         val (user :: server :: _) = jid.split("@").toList
  15.         this(user, server, password)
  16.     }
  17.  
  18.  
  19.  
  20.     def onMessage(chat:Chat, message:Message)
  21.     {
  22.         println("Stara :/")
  23.     }
  24.  
  25.     con.getChatManager.addChatListener(new ChatManagerListener
  26.     {
  27.             def chatCreated(chat:Chat, createdLocally:Boolean)
  28.             {
  29.                 chat.addMessageListener(new MessageListener
  30.                 {
  31.                     def processMessage(chat:Chat, message:Message) = onMessage(chat, message)
  32.                 })
  33.             }
  34.     })
  35. }
  36.  
  37. class Rss(connection:XMPPConnection) extends Service(connection)
  38. {
  39.     override def onMessage(chat:Chat, message:Message)
  40.     {
  41.         println(message.getBody);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement