Etoys: ScratchConnect-Richo.2.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Etoys: ScratchConnect-Richo.2.mcz

commits-2
Ricardo Moran uploaded a new version of ScratchConnect to project Etoys:
http://source.squeak.org/etoys/ScratchConnect-Richo.2.mcz

==================== Summary ====================

Name: ScratchConnect-Richo.2
Author: Richo
Time: 12 March 2012, 1:51:13 am
UUID: d8023660-e3f6-2e4c-8229-6a4ff1e157fe
Ancestors: ScratchConnect-Richo.1

Fixed a couple of potential issues detected after a more detailed code review:
* Disconnect the socket when deleting the morph.
* Changed a couple of sends in Player from "costume" to "costume renderedMorph", otherwise they would fail if the ScratchClientMorph is rotated.
* Changed #stepTime to only return 0 if the morph is connected, otherwise send "super stepTime".
* Changed to avoid connecting if another instance is already connected to the same host and port.

=============== Diff against ScratchConnect-Richo.1 ===============

Item was changed:
  ----- Method: Player>>broadcast: (in category '*scratchconnect') -----
  broadcast: aString
+ self costume renderedMorph broadcast: aString!
- self costume broadcast: aString!

Item was changed:
  ----- Method: Player>>receiveMessages (in category '*scratchconnect') -----
  receiveMessages
+ self costume renderedMorph receiveMessages!
- self costume receiveMessages!

Item was changed:
  ----- Method: Player>>sendSensorUpdateNamed:value: (in category '*scratchconnect') -----
  sendSensorUpdateNamed: aName value: aValue
+ self costume renderedMorph sendSensorUpdateNamed: aName value: aValue!
- self costume sendSensorUpdateNamed: aName value: aValue!

Item was changed:
  ----- Method: Player>>sendValues (in category '*scratchconnect') -----
  sendValues
  | updateParameters |
  updateParameters := Dictionary new.
  self slotNames
  do: [:slt | updateParameters
  at: slt
  put: (self
  perform: (Utilities getterSelectorFor: slt))].
+ self costume renderedMorph sendSensorUpdate: updateParameters!
- self costume sendSensorUpdate: updateParameters!

Item was changed:
  ----- Method: Player>>sensorUpdate: (in category '*scratchconnect') -----
  sensorUpdate: aString
+ self costume renderedMorph sendScratchCommand: 'sensor-update'
- self costume sendScratchCommand: 'sensor-update'
  , (aString convertToEncoding: 'UTF8')!

Item was added:
+ ----- Method: ScratchClientMorph>>delete (in category 'initialization') -----
+ delete
+ super delete.
+ self closeConnectionToScratch!

Item was added:
+ ----- Method: ScratchClientMorph>>isOtherInstanceConnectedTo:port: (in category 'private') -----
+ isOtherInstanceConnectedTo: host port: port
+ self class allInstancesDo: [:each |
+ (each isConnectedToScratch
+ and: [each scratchHost = host
+ and: [each scratchPort = port]])
+ ifTrue: [^ true]].
+ ^ false!

Item was changed:
  ----- Method: ScratchClientMorph>>openConnectionToScratch (in category 'private') -----
  openConnectionToScratch
  self isConnectedToScratch
  ifTrue: [^ self].
  (self scratchHost isNil
  or: [self scratchPort isNil])
  ifTrue: [^ self].
+ (self isOtherInstanceConnectedTo: self scratchHost port: self scratchPort)
+ ifTrue: [self error].
  scratchSocket
  ifNotNil: [[scratchSocket close]
  ensure: [scratchSocket := nil]].
  scratchSocket := SocketStream openConnectionToHostNamed: self scratchHost port: self scratchPort.
  scratchSocket binary.
  scratchSocket buffered: false.
  self updateIndicator.
  self isConnectedToScratch
  ifTrue: [self addLog: 'open connection: ' , self scratchHost , ':' , self scratchPort printString.
  self sayBalloon: 'open connection: ' , self scratchHost , ':' , self scratchPort printString.
  self isVerbose
  ifTrue: [self beep: 'meow']]!

Item was changed:
  ----- Method: ScratchClientMorph>>step (in category 'stepping and presenter') -----
  step
  self isConnectedToScratch
  ifTrue: [self receiveMessages].
+ self updateIndicator!
- self updateIndicator.
- super step!

Item was changed:
+ ----- Method: ScratchClientMorph>>stepTime (in category 'stepping and presenter') -----
- ----- Method: ScratchClientMorph>>stepTime (in category 'testing') -----
  stepTime
+ ^ self isConnectedToScratch
+ ifTrue: [0]
+ ifFalse: [super stepTime]!
- ^ 0!

_______________________________________________
etoys-dev mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/etoys-dev