1515import com .facebook .react .bridge .ReactMethod ;
1616import com .facebook .react .bridge .ReadableMap ;
1717import com .facebook .react .bridge .WritableMap ;
18- import com .facebook .react .bridge .GuardedAsyncTask ;
1918import com .facebook .react .bridge .Callback ;
2019import com .facebook .react .modules .core .DeviceEventManagerModule ;
2120
@@ -71,9 +70,9 @@ private void sendEvent(String eventName, WritableMap params) {
7170 @ SuppressWarnings ("unused" )
7271 @ ReactMethod
7372 public void connect (@ NonNull final Integer cId , @ NonNull final String host , @ NonNull final Integer port , @ NonNull final ReadableMap options ) {
74- new GuardedAsyncTask < Void , Void >( mReactContext . getExceptionHandler () ) {
73+ executorService . execute ( new Thread ( new Runnable ( ) {
7574 @ Override
76- protected void doInBackgroundGuarded ( Void ... params ) {
75+ public void run ( ) {
7776 TcpSocketClient client = socketClients .get (cId );
7877 if (client != null ) {
7978 onError (cId , TAG + "createSocket called twice with the same id." );
@@ -92,16 +91,16 @@ protected void doInBackgroundGuarded(Void... params) {
9291 onError (cId , e .getMessage ());
9392 }
9493 }
95- }. executeOnExecutor ( executorService );
94+ }) );
9695 }
9796
9897 @ SuppressLint ("StaticFieldLeak" )
9998 @ SuppressWarnings ("unused" )
10099 @ ReactMethod
101100 public void write (@ NonNull final Integer cId , @ NonNull final String base64String , @ Nullable final Callback callback ) {
102- new GuardedAsyncTask < Void , Void >( mReactContext . getExceptionHandler () ) {
101+ executorService . execute ( new Thread ( new Runnable ( ) {
103102 @ Override
104- protected void doInBackgroundGuarded ( Void ... params ) {
103+ public void run ( ) {
105104 TcpSocketClient socketClient = socketClients .get (cId );
106105 if (socketClient == null ) {
107106 return ;
@@ -118,24 +117,24 @@ protected void doInBackgroundGuarded(Void... params) {
118117 onError (cId , e .toString ());
119118 }
120119 }
121- }. executeOnExecutor ( executorService );
120+ }) );
122121 }
123122
124123 @ SuppressLint ("StaticFieldLeak" )
125124 @ SuppressWarnings ("unused" )
126125 @ ReactMethod
127126 public void end (final Integer cId ) {
128- new GuardedAsyncTask < Void , Void >( mReactContext . getExceptionHandler () ) {
127+ executorService . execute ( new Thread ( new Runnable ( ) {
129128 @ Override
130- protected void doInBackgroundGuarded ( Void ... params ) {
129+ public void run ( ) {
131130 TcpSocketClient socketClient = socketClients .get (cId );
132131 if (socketClient == null ) {
133132 return ;
134133 }
135134 socketClient .close ();
136135 socketClients .remove (cId );
137136 }
138- }. executeOnExecutor ( executorService );
137+ }) );
139138 }
140139
141140 @ SuppressWarnings ("unused" )
@@ -148,9 +147,9 @@ public void destroy(final Integer cId) {
148147 @ SuppressWarnings ("unused" )
149148 @ ReactMethod
150149 public void listen (final Integer cId , final ReadableMap options ) {
151- new GuardedAsyncTask < Void , Void >( mReactContext . getExceptionHandler () ) {
150+ executorService . execute ( new Thread ( new Runnable ( ) {
152151 @ Override
153- protected void doInBackgroundGuarded ( Void ... params ) {
152+ public void run ( ) {
154153 try {
155154 TcpSocketServer server = new TcpSocketServer (socketClients , TcpSocketModule .this , cId , options );
156155 socketClients .put (cId , server );
@@ -161,7 +160,7 @@ protected void doInBackgroundGuarded(Void... params) {
161160 onError (cId , uhe .getMessage ());
162161 }
163162 }
164- }. executeOnExecutor ( executorService );
163+ }) );
165164 }
166165
167166 @ SuppressWarnings ("unused" )
0 commit comments