RocketChat/Rocket.Chat.PCL

Name: Rocket.Chat.PCL

Owner: Rocket.Chat

Description: Portable Class Libraries - Xamarin implementation of the Rocket.Chat Real-Time API

Created: 2017-02-09 17:10:42.0

Updated: 2018-02-28 15:25:39.0

Pushed: 2017-03-18 20:19:29.0

Homepage: null

Size: 78

Language: C#

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Rocket.Chat logo

Xamarin bindings for Rocket.Chat

Using in your Xamarin project

In order to use the bindings, you will need the latest version of Xamarin Studio for Mac or Visual Studio on windows.

Nuget repository

MeteorPCL and Rocket.Chat.PCL are currently both distrbuted on the following public MyGet repository. They will be uploaded to nuget.org in the future. For now, you'll need to add the following NuGet feed to your sources:

tps://www.myget.org/F/shauncampbell/api/v2
Usage
Limitations
Establishing a connection

In the following example we are connecting to demo.rocket.chat, on port 443 (https) with SSL enabled. We connect to the server and print out a list of the subscribed rooms.

g RocketChatPCL;

 client = new RocketChatClient("demo.rocket.chat", 443, true);
ent.Connect("testuser", "testpass")
   .ContinueWith( (connected) => {
      foreach (var room in rc.Rooms.Keys) {
         Debug.WriteLine("Room: {0}", rc.Rooms[room].Name);
      }
  });
Collections

There are currently 4 collections:

Users Collection

The user object has the following properties. Depending on the circumstance in which it has been instantitaed it may not always have all of these properties. However User objects retrieved from the user collection should always have these items:

g RocketChatPCL;

 client = new RocketChatClient("demo.rocket.chat", 443, true);
ent.Connect("testuser", "testpass")
   .ContinueWith( (connected) => {
      foreach (var user in rc.Users.Keys) {
         Debug.WriteLine("User: {0} is in the '{1} timezone", 
                         rc.Users[user].Username, rc.Users[user].UtcOffset);
      }
  });
Rooms Collection

The room object has the following properties:

Load History
History (DateTime oldestMessage, int quantity, DateTime lastUpdate);

It is possible to load all messages in the room using this method. You would usually use this method to perform the initial load of messages into your application and then use subscriptions to retrieve messages thereafter.

History(new DateTime(1970, 1, 1), 100, DateTime.Now)
.ContinueWith( (messages) => {
    foreach (var msg in messages.Result)
        Debug.WriteLine("Message from: {0}: {1}", message.User.Username, message.Text);    
});
Send Message
Message (string message);

This method sends a message to the room.

License

This library is distributed under the MIT License.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.