• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

ObjectStream client-server object sharing problem.

 
Ranch Hand
Posts: 67
PHP Debian Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Currently there is no syntax problems so the code runs.
Problems what i am having now are
*When client connects and i add it to ActiveSessions, there will be added two instances at the same time(should be only one)

* On client side, pushing button send the object sending and receving works, but the client get's always the same Board object somehow. Like the turns count increases on server side but on client side the counter stays same, always 1 1 1.

As on the server side there's object Board and i share only objects reference to other sessionhandlers this should avoid the problem of making somewhere two different instances.

server main


Client side
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two instances at the same time is added, because on client side you create two sockets, on line 23 and on line 79.

Client gets the same Board object because on server side it should be not just send (like you do on line 115), but first cloned. To do this you should implement Cloneable interface in Board class and override clone() method ibid. Then line 115 should look like this:
 
It runs on an internal combustion engine. This ad does not:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic