static private void recv_callback(IAsyncResult ar) { End_Point ep = (End_Point)ar.AsyncState; try { int ret = ep.socket_.EndReceive(ar); if (ret > 0) { ep.player_.player_log("从服务器接收" + ret + "字节数据"); Byte_Buffer buffer = ep.get_buffer(ret); Game_Manager.instance.process_buffer(ep, buffer); ep.recv(); } } catch (Exception ex) { ep.disconnect(); if (ep.player_.robot_status != 0) { Game_Manager.instance.rmv_player(ep.player_); } //Log.debug_log(ex.Message); } }
static private void connect_callback(IAsyncResult ar) { End_Point ep = (End_Point)ar.AsyncState; try { ep.socket_.EndConnect(ar); ep.connect_status = true; ep.player_.player_log("连接" + ep.ip_ + ":" + ep.port_.ToString() + "成功"); if (ep.player_.robot_status != 0) { ep.player_.req_connect_gate(); } else { Game_Manager.instance.add_player(ep.player_); ep.player_.req_select_gate(); } ep.recv(); } catch (Exception ex) { Log.debug_log(ex.Message); ep.player_.player_log("连接" + ep.ip_ + ":" + ep.port_.ToString() + "失败"); } }
static private void send_callback(IAsyncResult ar) { End_Point ep = (End_Point)ar.AsyncState; try { int ret = ep.socket_.EndSend(ar); ep.player_.player_log("向服务器发送了" + ret + "字节数据"); } catch (Exception ex) { //Log.debug_log(ex.Message); } }