Method: MatrixSdk::Client#initialize
- Defined in:
- lib/matrix_sdk/client.rb
#initialize(hs_url, client_cache: :all, **params) ⇒ Client
Returns a new instance of Client.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/matrix_sdk/client.rb', line 37 def initialize(hs_url, client_cache: :all, **params) event_initialize params[:user_id] ||= params[:mxid] if params[:mxid] if hs_url.is_a? Api @api = hs_url params.each do |k, v| api.instance_variable_set("@#{k}", v) if api.instance_variable_defined? "@#{k}" end else @api = Api.new hs_url, params end @rooms = {} @users = {} @cache = client_cache @identity_server = params.fetch(:identity_server, nil) @sync_token = nil @sync_thread = nil @sync_filter = { room: { timeline: { limit: params.fetch(:sync_filter_limit, 20) }, state: { lazy_load_members: true } } } @should_listen = false @next_batch = nil @bad_sync_timeout_limit = 60 * 60 params.each do |k, v| instance_variable_set("@#{k}", v) if instance_variable_defined? "@#{k}" end raise ArgumentError, 'Cache value must be one of of [:all, :some, :none]' unless i[all some none].include? @cache return unless params[:user_id] @mxid = params[:user_id] end |