mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-09 22:00:39 +01:00
open connection to relay in the network thread, not in UI thread. It
can block for a while.
This commit is contained in:
parent
cbb7f5ff4f
commit
27f65ba39d
1 changed files with 16 additions and 13 deletions
|
@ -118,6 +118,22 @@ public class CommsTransport extends Thread implements TransportProcs {
|
||||||
while ( !m_done ) {
|
while ( !m_done ) {
|
||||||
try {
|
try {
|
||||||
synchronized( this ) {
|
synchronized( this ) {
|
||||||
|
|
||||||
|
// if we have data and no socket, try to connect.
|
||||||
|
if ( null == m_socketChannel
|
||||||
|
&& 0 < m_buffersOut.size() ) {
|
||||||
|
try {
|
||||||
|
m_socketChannel = SocketChannel.open();
|
||||||
|
m_socketChannel.configureBlocking( false );
|
||||||
|
InetSocketAddress isa
|
||||||
|
= new InetSocketAddress( m_addr.ip_relay_hostName,
|
||||||
|
m_addr.ip_relay_port );
|
||||||
|
m_socketChannel.connect( isa );
|
||||||
|
} catch ( java.io.IOException ioe ) {
|
||||||
|
Utils.logf( ioe.toString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( null != m_socketChannel ) {
|
if ( null != m_socketChannel ) {
|
||||||
int ops = figureOps();
|
int ops = figureOps();
|
||||||
Utils.logf( "calling with ops=%x", ops );
|
Utils.logf( "calling with ops=%x", ops );
|
||||||
|
@ -184,19 +200,6 @@ public class CommsTransport extends Thread implements TransportProcs {
|
||||||
m_buffersOut.add( netbuf );
|
m_buffersOut.add( netbuf );
|
||||||
Assert.assertEquals( netbuf.remaining(), 0 );
|
Assert.assertEquals( netbuf.remaining(), 0 );
|
||||||
|
|
||||||
if ( null == m_socketChannel ) {
|
|
||||||
try {
|
|
||||||
m_socketChannel = SocketChannel.open();
|
|
||||||
m_socketChannel.configureBlocking( false );
|
|
||||||
InetSocketAddress isa
|
|
||||||
= new InetSocketAddress( m_addr.ip_relay_hostName,
|
|
||||||
m_addr.ip_relay_port );
|
|
||||||
m_socketChannel.connect( isa );
|
|
||||||
} catch ( java.io.IOException ioe ) {
|
|
||||||
Utils.logf( ioe.toString() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( null != m_selector ) {
|
if ( null != m_selector ) {
|
||||||
m_selector.wakeup(); // tell it it's got some writing to do
|
m_selector.wakeup(); // tell it it's got some writing to do
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue