@@ -70,7 +70,7 @@ pub struct Service {
7070 capture_status : Rc < Cell < Status > > ,
7171 pub ( crate ) emulation_status : Rc < Cell < Status > > ,
7272 pub ( crate ) should_release : Rc < RefCell < Option < ReleaseToken > > > ,
73- incoming_conns : Rc < RefCell < HashMap < ClientHandle , ( String , SocketAddr ) > > > ,
73+ incoming_conns : Rc < RefCell < HashMap < ClientHandle , ( String , SocketAddr , Position ) > > > ,
7474 cert : Certificate ,
7575 next_trigger_handle : u64 ,
7676}
@@ -225,34 +225,42 @@ impl Service {
225225 Ok ( ( ) )
226226 }
227227
228+ pub ( crate ) const ENTER_HANDLE_BEGIN : u64 = u64:: MAX / 2 + 1 ;
229+
228230 fn add_incoming (
229231 & mut self ,
230232 addr : SocketAddr ,
231233 pos : Position ,
232234 fingerprint : String ,
233235 capture : & Capture ,
234236 ) {
235- const ENTER_HANDLE_BEGIN : u64 = u64:: MAX / 2 + 1 ;
236- let handle = ENTER_HANDLE_BEGIN + self . next_trigger_handle ;
237+ let handle = Self :: ENTER_HANDLE_BEGIN + self . next_trigger_handle ;
237238 self . next_trigger_handle += 1 ;
238239 capture. create ( handle, pos) ;
239240 self . incoming_conns
240241 . borrow_mut ( )
241- . insert ( handle, ( fingerprint, addr) ) ;
242+ . insert ( handle, ( fingerprint, addr, pos ) ) ;
242243 }
243244
244245 fn remove_incoming ( & mut self , addr : SocketAddr , capture : & Capture ) -> Option < String > {
245246 let handle = self
246247 . incoming_conns
247248 . borrow ( )
248249 . iter ( )
249- . find ( |( _, ( _, a) ) | * a == addr)
250+ . find ( |( _, ( _, a, _ ) ) | * a == addr)
250251 . map ( |( k, _) | * k) ?;
251252 capture. destroy ( handle) ;
252253 self . incoming_conns
253254 . borrow_mut ( )
254255 . remove ( & handle)
255- . map ( |( f, _) | f)
256+ . map ( |( f, _, _) | f)
257+ }
258+
259+ pub ( crate ) fn get_incoming_pos ( & self , handle : ClientHandle ) -> Option < Position > {
260+ self . incoming_conns
261+ . borrow ( )
262+ . get ( & handle)
263+ . map ( |& ( _, _, p) | p)
256264 }
257265
258266 fn notify_frontend ( & self , event : FrontendEvent ) {
0 commit comments