equal
deleted
inserted
replaced
96 lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); |
96 lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); |
97 llm_connection_bless (cb->L, connection); |
97 llm_connection_bless (cb->L, connection); |
98 // XXX lm_connection_unref (connection); |
98 // XXX lm_connection_unref (connection); |
99 lua_pushboolean (cb->L, success); |
99 lua_pushboolean (cb->L, success); |
100 if (lua_pcall (cb->L, 2, 0, 0)) { |
100 if (lua_pcall (cb->L, 2, 0, 0)) { |
101 E ("Connection callback error: %s", lua_tostring (cb->L, -1)); |
101 W ("Connection callback error: %s", lua_tostring (cb->L, -1)); |
102 lua_pop (cb->L, 1); |
102 lua_pop (cb->L, 1); |
103 } |
103 } |
104 } |
104 } |
105 |
105 |
106 /// connection:open |
106 /// connection:open |
122 cb, (GDestroyNotify) llm_callback_destroy, &err)) |
122 cb, (GDestroyNotify) llm_callback_destroy, &err)) |
123 return 1; |
123 return 1; |
124 else { |
124 else { |
125 lua_pushnil (L); |
125 lua_pushnil (L); |
126 lua_pushstring (L, err->message); |
126 lua_pushstring (L, err->message); |
127 W ("Connection opening failed"); |
127 I ("Connection opening failed"); |
128 return 2; |
128 return 2; |
129 } |
129 } |
130 } |
130 } |
131 |
131 |
132 /// connection:authenticate |
132 /// connection:authenticate |
154 lua_pop (L, 3); |
154 lua_pop (L, 3); |
155 return 1; |
155 return 1; |
156 } else { |
156 } else { |
157 lua_pushnil (L); |
157 lua_pushnil (L); |
158 lua_pushstring (L, err->message); |
158 lua_pushstring (L, err->message); |
159 W ("Connection authentication failed: %s", err->message); |
159 I ("Connection authentication failed: %s", err->message); |
160 return 2; |
160 return 2; |
161 } |
161 } |
162 } |
162 } |
163 |
163 |
164 /// connection:port |
164 /// connection:port |
225 } else { // Get |
225 } else { // Get |
226 #ifdef HAVE_LM_CONNECTION_GET_KEEP_ALIVE_RATE |
226 #ifdef HAVE_LM_CONNECTION_GET_KEEP_ALIVE_RATE |
227 lua_pushnumber (L, lm_connection_get_keep_alive_rate (object->connection)); |
227 lua_pushnumber (L, lm_connection_get_keep_alive_rate (object->connection)); |
228 return 1; |
228 return 1; |
229 #else |
229 #else |
230 E ("Sorry, your loudmouth have no get_keep_alive_rate ()"); |
230 W ("Sorry, your loudmouth have no get_keep_alive_rate ()"); |
231 lua_pushnil (L); |
231 lua_pushnil (L); |
232 lua_pushstring (L, "Sorry, your loudmouth have no get_keep_alive_rate ()"); |
232 lua_pushstring (L, "Sorry, your loudmouth have no get_keep_alive_rate ()"); |
233 return 2; |
233 return 2; |
234 #endif |
234 #endif |
235 } |
235 } |
289 llm_connection_t *object = luaL_checklm_connection (L, 1); |
289 llm_connection_t *object = luaL_checklm_connection (L, 1); |
290 GError *err = NULL; |
290 GError *err = NULL; |
291 if (lm_connection_close (object->connection, &err)) |
291 if (lm_connection_close (object->connection, &err)) |
292 return 1; |
292 return 1; |
293 else { |
293 else { |
294 W ("Connection close failed: %s", err->message); |
294 I ("Connection close failed: %s", err->message); |
295 lua_pushnil (L); |
295 lua_pushnil (L); |
296 lua_pushstring (L, err->message); |
296 lua_pushstring (L, err->message); |
297 return 2; |
297 return 2; |
298 } |
298 } |
299 } |
299 } |
342 }; |
342 }; |
343 lua_pop (L, 1); |
343 lua_pop (L, 1); |
344 if (status) |
344 if (status) |
345 return 1; |
345 return 1; |
346 else { |
346 else { |
347 W ("Message sending failed: %s", err->message); |
347 I ("Message sending failed: %s", err->message); |
348 lua_pushnil (L); |
348 lua_pushnil (L); |
349 lua_pushstring (L, err->message); |
349 lua_pushstring (L, err->message); |
350 return 2; |
350 return 2; |
351 } |
351 } |
352 } |
352 } |
362 GError *err = NULL; |
362 GError *err = NULL; |
363 if (lm_connection_send_raw (object->connection, string, NULL)) { |
363 if (lm_connection_send_raw (object->connection, string, NULL)) { |
364 lua_pop (L, 1); |
364 lua_pop (L, 1); |
365 return 1; |
365 return 1; |
366 } else { |
366 } else { |
367 W ("Raw message sending failed: %s", err->message); |
367 I ("Raw message sending failed: %s", err->message); |
368 lua_pushnil (L); |
368 lua_pushnil (L); |
369 lua_pushstring (L, err->message); |
369 lua_pushstring (L, err->message); |
370 return 2; |
370 return 2; |
371 } |
371 } |
372 } |
372 } |
424 lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); |
424 lua_rawgeti (cb->L, LUA_REGISTRYINDEX, cb->reference); |
425 llm_connection_bless (cb->L, connection); |
425 llm_connection_bless (cb->L, connection); |
426 // XXX lm_connection_unref (connection); |
426 // XXX lm_connection_unref (connection); |
427 luaL_pushenum (cb->L, reason, llm_disconnect_reason); |
427 luaL_pushenum (cb->L, reason, llm_disconnect_reason); |
428 if (lua_pcall (cb->L, 2, 0, 0)) { |
428 if (lua_pcall (cb->L, 2, 0, 0)) { |
429 E ("Disconnect callback error: %s", lua_tostring (cb->L, -1)); |
429 W ("Disconnect callback error: %s", lua_tostring (cb->L, -1)); |
430 lua_pop (cb->L, 1); |
430 lua_pop (cb->L, 1); |
431 } |
431 } |
432 } |
432 } |
433 |
433 |
434 /// connection:ondisconnect |
434 /// connection:ondisconnect |
459 llm_connection_t *object = luaL_checklm_connection (L, 1); |
459 llm_connection_t *object = luaL_checklm_connection (L, 1); |
460 GError *err = NULL; |
460 GError *err = NULL; |
461 if (lm_connection_open_and_block (object->connection, &err)) |
461 if (lm_connection_open_and_block (object->connection, &err)) |
462 return 1; |
462 return 1; |
463 else { |
463 else { |
464 W ("Synchronous connection opening failed: %s", err->message); |
464 I ("Synchronous connection opening failed: %s", err->message); |
465 lua_pushnil (L); |
465 lua_pushnil (L); |
466 lua_pushstring (L, err->message); |
466 lua_pushstring (L, err->message); |
467 return 2; |
467 return 2; |
468 } |
468 } |
469 } |
469 } |
481 GError *err = NULL; |
481 GError *err = NULL; |
482 if (lm_connection_authenticate_and_block (object->connection, username, |
482 if (lm_connection_authenticate_and_block (object->connection, username, |
483 password, resource, &err)) |
483 password, resource, &err)) |
484 return 1; |
484 return 1; |
485 else { |
485 else { |
486 W ("Synchronous authentication failed: %s", err->message); |
486 I ("Synchronous authentication failed: %s", err->message); |
487 lua_pushnil (L); |
487 lua_pushnil (L); |
488 lua_pushstring (L, err->message); |
488 lua_pushstring (L, err->message); |
489 return 2; |
489 return 2; |
490 } |
490 } |
491 } |
491 } |
500 llm_message_t *message = luaL_checklm_message (L, 2); |
500 llm_message_t *message = luaL_checklm_message (L, 2); |
501 GError *err = NULL; |
501 GError *err = NULL; |
502 LmMessage *new = lm_connection_send_with_reply_and_block (object->connection, |
502 LmMessage *new = lm_connection_send_with_reply_and_block (object->connection, |
503 message->message, &err); |
503 message->message, &err); |
504 if (!new) { |
504 if (!new) { |
505 W ("Synchronous message sending failed: %s", err->message); |
505 I ("Synchronous message sending failed: %s", err->message); |
506 lua_pushnil (L); |
506 lua_pushnil (L); |
507 lua_pushstring (L, err->message); |
507 lua_pushstring (L, err->message); |
508 return 2; |
508 return 2; |
509 } else { |
509 } else { |
510 llm_message_bless (L, new); |
510 llm_message_bless (L, new); |