Source

ios_ezcomet_api / ezcomet_api / example / DemoViewController.m

Full commit
//
//  DemoViewController.m
//  ezcomet_api
//
//  Created by Chung-Che Hsieh on 12/7/30.
//  Copyright (c) 2012年 a761007@gmail.com. All rights reserved.
//

#import "DemoViewController.h"

@interface DemoViewController ()

@end

@implementation DemoViewController

@synthesize username;
@synthesize channel;
@synthesize message;
@synthesize pushMessageButton;
@synthesize getMessagesButton;
@synthesize flushMessagesButton;

- (void) ezcomet:(EZComet *)ezcomet flushMessagesDidSucessWithTick:(NSString *)tick
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"msg"
                                                    message:tick
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil, nil];
    [alert show];    
}

- (void) ezcomet:(EZComet *)ezcomet flushMessagesDidFailWithErrorMessage:(NSString *)err_msg
{
    NSLog(@"%s:%@", __PRETTY_FUNCTION__, err_msg);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"msg"
                                                    message:err_msg
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil, nil];
    [alert show];
}

- (IBAction)flushMessages:(id)sender
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
    EZComet *comet = [EZComet shareInstance];
    comet.delegate = self;
    [comet flushMessagesWithUserName:username.text
                             Channel:channel.text];
    
}

- (void) ezcomet:(EZComet *)ezcomet pushMessageDidSucessWithTick:(NSString *)tick
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"msg"
                                                    message:tick
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil, nil];
    [alert show];    
}

- (void) ezcomet:(EZComet *)ezcomet pushMessageDidFailWithErrorMessage:(NSString *)err_msg
{
    NSLog(@"%s:%@", __PRETTY_FUNCTION__, err_msg);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"msg"
                                                    message:err_msg
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil, nil];
    [alert show];
}

- (IBAction)pushMessage:(id)sender
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
    EZComet *comet = [EZComet shareInstance];
    comet.delegate = self;
    [comet pushMessageWithUserName:username.text
                           Channel:channel.text
                           Message:message.text];
    
}

- (void) ezcomet:(EZComet *)ezcomet getMessagesDidSucessWithMessages:(NSArray *)messages
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"msg"
                                                    message:[messages description]
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil, nil];
    [alert show];
}

- (void) ezcomet:(EZComet *)ezcomet getMessagesDidFailWithErrorMessage:(NSString *)err_msg
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"msg"
                                                    message:err_msg
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil, nil];
    [alert show];
}

- (IBAction)getMessages:(id)sender
{
    NSLog(@"%s", __PRETTY_FUNCTION__);
    EZComet *comet = [EZComet shareInstance];
    comet.delegate = self;
    [comet getMessagesWithUserName:username.text
                           Channel:channel.text
                           Tick:nil];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end