Class: Wiretap::ServerList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/wiretap.rb,
ext/serverlist.cpp

Instance Method Summary collapse

Constructor Details

#initializeObject

ServerList doesn’t require any params for initialization



100
101
102
# File 'ext/serverlist.cpp', line 100

static VALUE wiretap_server_list_initialize(VALUE self) {
	return self;
}

Instance Method Details

#[](index) ⇒ Object

Get server by it’s index



132
133
134
135
136
137
138
139
# File 'ext/serverlist.cpp', line 132

static VALUE wiretap_server_list_get_at(VALUE self, VALUE index) {
	WireTapServerList* server_list;
	Data_Get_Struct(self, WireTapServerList, server_list);

	WireTapServerList::ServerInfo node;
	RUN_E(server_list->getNode(FIX2INT(index), node), server_list);
  return wiretap_server_info_create(node);; 
}

#countObject

Number of available servers



120
121
122
123
124
125
126
127
# File 'ext/serverlist.cpp', line 120

static VALUE wiretap_server_list_count(VALUE self) {
	WireTapServerList* server_list;
	Data_Get_Struct(self, WireTapServerList, server_list);

	int num = 0;
	RUN_E(server_list->getNumNodes(num), server_list);
	return INT2FIX(num);
}

#eachObject

Eval block on each server



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'ext/serverlist.cpp', line 144

static VALUE wiretap_server_list_each(VALUE self) {
	WireTapServerList* server_list;
	Data_Get_Struct(self, WireTapServerList, server_list);

	int num;
	
	RUN_E(server_list->getNumNodes(num), server_list);

	for(int i = 0; i < num; i++) {
		WireTapServerList::ServerInfo node;
		RUN_E(server_list->getNode(i, node), server_list);
	  rb_yield(wiretap_server_info_create(node));
	}
	return self;
}

#lengthObject



51
# File 'lib/wiretap.rb', line 51

def length; count; end

#resolve(storage) ⇒ Object

Resolve server by it’s storage ID



107
108
109
110
111
112
113
114
115
# File 'ext/serverlist.cpp', line 107

static VALUE wiretap_server_list_resolve(VALUE self, VALUE storage) {
	WireTapServerList* server_list;
	Data_Get_Struct(self, WireTapServerList, server_list);

	WireTapServerId host;
	RUN_E(server_list->resolveStorageId(CSTR(storage), host), server_list);
	return Qnil;
	//return wiretap_to_str(host);
}