Skip to content

Instantly share code, notes, and snippets.

View Gustash's full-sized avatar
🦀
Would Captain Shu code in Rust?

Gustash Gustash

🦀
Would Captain Shu code in Rust?
  • USTWO
  • Lisbon, Portugal
View GitHub Profile
func subscribeChannel(channel: String) {
if (appDelegate.ortc?.isConnected() == true) {
appDelegate.ortc?.subscribe(channel)
} else {
print("Ortc not connected yet.")
}
}
func sendMessage(channel: String, message: String) {
if (appDelegate.ortc?.isConnected() == true) {
@IBAction func subscribeButtonClick(sender: AnyObject) {
subscribeChannel("general")
}
@IBAction func messageButtonClick(sender: AnyObject) {
sendMessage("general", message: "Hello World!")
}
let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
import UIKit
import Parse
@UIApplicationMain
class AppDelegate: RealtimePushAppDelegate {
var ortc: OrtcClass?
var notifications:NSMutableDictionary = NSMutableDictionary()
override func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var ortc: OrtcClass?
import UIKit
class OrtcClass: NSObject, OrtcClientDelegate{
let APPKEY = "YOUR_APP_KEY"
let TOKEN = "TOKEN"
let METADATA = "METADATA"
let URL = "https://ortc-developers.realtime.co/server/ssl/2.1/"
var ortc: OrtcClient?
var onMessage:AnyObject?
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import “OrtcClient.h”
#import <RealtimePushAppDelegate.h>
#endif /* Bridging_Header_h */
private void subscribeOrtc() {
if (subscription.isOrtcConnected()) {
subscription.subscribeChannel("general");
} else {
Toast.makeText(this, "Ortc not connected yet, try again in a few seconds.",
Toast.LENGTH_SHORT).show();
}
}
private void messageOrtc() {
subscribeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subscribeOrtc();
}
});
messageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subscription = new SubscriptionHandler(this);
Button subscribeButton = (Button) findViewById(R.id.subscribeButton);
Button messageButton = (Button) findViewById(R.id.messageButton);