libfchat 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,31 +4,53 @@ module Libfchat
4
4
  rescue LoadError
5
5
  #I don't actually NEED rubygems, unless on 1.8
6
6
  end
7
- require 'net/http'
8
7
  require 'multi_json'
9
8
  require 'eventmachine'
10
9
  require 'em-http-request'
10
+ require 'libfchat/version'
11
11
  require 'libfchat/webapi'
12
12
 
13
13
  class Fchat
14
14
  attr_reader :ticket
15
+ attr_accessor :http
15
16
 
16
- def login(server,account,password,timeout=30)
17
+ attr_reader :version
18
+ attr_reader :clientname
19
+
20
+ def initialize(clientname="libfchat-ruby by Jippen Faddoul ( http://github.com/jippen/libfchat-ruby )",version=Libfchat::VERSION)
21
+ @clientname = clientname
22
+ @version = version
23
+ end
24
+
25
+ def login(server,account,password,character,timeout=30)
17
26
  webapi = Libfchat::WebAPI.new
18
27
  @ticket = webapi.get_ticket(account,password)
19
28
 
20
29
  EventMachine.run {
21
- http = EventMachine::HttpRequest.new(server).get :timeout => timeout
22
- http.errback { puts "Could not connect to " + server }
23
- http.callback {
30
+ self.http = EventMachine::HttpRequest.new(server).get :timeout => timeout
31
+ self.http.errback { puts "Could not connect to " + server }
32
+ self.http.callback {
24
33
  puts "Websocket connected"
34
+ self.IDN()
25
35
  }
26
36
 
27
- http.stream { |msg|
37
+ self.http.stream { |msg|
28
38
  puts "Received: #{msg}"
29
39
  }
30
40
  }
31
41
  end
32
42
 
43
+ def IDN(account,character,ticket,cname=@clientname,cversion=@version,method="ticket")
44
+ # Initial identification with the server
45
+ json = {:account => account,
46
+ :character => character,
47
+ :ticket => ticket,
48
+ :cname => cname,
49
+ :cversion => cversion,
50
+ :method => ticket}
51
+ self.http.send( "IDN " + MultiJson.dump(json) )
52
+ end
53
+
54
+
33
55
  end
34
56
  end
@@ -2,5 +2,5 @@ module Libfchat
2
2
  # We're doing this because we might write tests that deal
3
3
  # with other versions of Libfchat and we are unsure how to
4
4
  # handle this better.
5
- VERSION = "0.1.3" unless defined?(::Libfchat::VERSION)
5
+ VERSION = "0.1.4" unless defined?(::Libfchat::VERSION)
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libfchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: