[Cuis] [aida] [ANN] A first port to Cuis of Sport and Swazoo

Janko Mivšek janko.mivsek at eranova.si
Mon Jan 21 08:50:36 CST 2013


Germán,

I put your process changes on VW Swazoo and here is the result, which is
probably least common denominator to all dialects:


HTTPServer>>start
 self loop isNil ifTrue:
   [self socket:
      (SwazooSocket serverOnIP: self ipCorrected port: self port).
   self socket listenFor: 128.
   self loop:
      [ [self acceptConnection] repeat]
           newProcess.
   self loop
      priority: Processor userBackgroundPriority;
      resume
   ]


Additionally:

HTTPConnection>>interact

  ...

  self server isMultiThreading
    ifTrue:
      [self loop: interactionBlock newProcess.
       self loop
         priority: Processor userBackgroundPriority;
         resume]
    ifFalse: [interactionBlock value].
  ^self


ServerTest>>setUp doesn't seem to have the process problem (process is
not stored in any variable, so I propose to leave this method unchanged.

Best regards
Janko


Dne 20. 01. 2013 16:59, piše Germán Arduino:
> Hi:
> 
> The first versions of Sport and Swazoo working in Cuis 4.1 with all
> tests green are ready to install.
> 
> The changes I did in Swazoo are:
> 
> 
> - Avoid Unicode support that don't exist in Cuis
> 
> 
> WebSocketConnection:
> 
> fromUtf8: aString
> "Squeak specific"
> 
> "gsa 14/01/2013 for Cuis port"
> "^[aString convertFromEncoding: #utf8] on: Error do: [:ex | aString ]
> ^ aString
> 
> 
> toUtf8: aString
> "Squeak specific"
> "
> | converter in out |
> converter := UTF8TextConverter new.
> in := aString readStream.
> out := WriteStream on: ''.
> [in atEnd] whileFalse:
> [converter nextPut: in next toStream: out].
> ^out contents
> "
> ^ aString.
> 
> 
> SwazooBuffer >>closeChunkTo: aSocket
> 
> 	" gsa 18/01/2013 used String instead ByteString for Cuis"
> 	"chunk := ByteString new: 5."
> 
> 
> - Avoid #fork and #forkAt: calling #newProcess instead:
> 
> HTTPServer >>start
> 
> start
> 	| swazooProcess |
> 	self loop isNil ifTrue: [
> 		self socket:
> 			(SwazooSocket
> 				serverOnIP: self ipCorrected
> 				port: self port).
> 		self socket listenFor: 128.
> 		self loop: (swazooProcess _ [ [ self acceptConnection ] repeat ] newProcess).
> 		swazooProcess name: 'Swazoo ' , DateAndTime now asString.
> 		swazooProcess priority: Processor userBackgroundPriority.
> 		swazooProcess resume ].
> 
> instead of the original code:
> 
> start
> 	self loop isNil ifTrue: [
> 		self socket:
> 			(SwazooSocket
> 				serverOnIP: self ipCorrected
> 				port: self port).
> 		self socket listenFor: 128.
> 		self loop: ([ [ self acceptConnection ] repeat ] forkAt: Processor
> userBackgroundPriority) ].
> 
> 
> 
> HTTPServer >>setUp
> 
> setUp
> 	| socket swazooProcess |
> 	(Delay forMilliseconds: 100) wait.
> 	server _ HTTPServer new.
> 	swazooProcess _ [
> 	server
> 		 ip: 'localhost';
> 		 port: 8123.
> 	server start ] newProcess.
> 	swazooProcess name: 'Swazoo HTTPServer Test'.
> 	swazooProcess resume.
> 	(Delay forMilliseconds: 100) wait.
> 	" 	stream := (SocketAccessor newTCPclientToHost: 'localhost' port: 8123)
> 				readAppendStream"
> 	socket _ SpSocket
> 		connectToServerOnHost: 'localhost'
> 		port: 8123.
> 	stream _ SwazooStream socket: socket.
> 
> instead of the original code:
> 
> setUp
> 	| socket |
> 	(Delay forMilliseconds: 100) wait.
> 	server := HTTPServer new.
> 	[server ip: 'localhost'; port: 8123.
> 	server start]
> 		fork.
> 	(Delay forMilliseconds: 100) wait.
> " 	stream := (SocketAccessor newTCPclientToHost: 'localhost' port: 8123)
> 				readAppendStream"
> 	socket := SpSocket connectToServerOnHost:  'localhost' port: 8123.
> 	stream := SwazooStream socket: socket
> 
> 
> Other considerations:
> 
> SpFilename >>underlyingFilename (This method do not exist, but do not
> exist neither in the original one click aida/pharo image)
> 
> Security class don't exist neither in the pharo one click image.
> 
> #trimSeparators, is named in SwazooMD5 but do not seems implemented.
> 
> 
> 
> 
> To install Sport and Swazoo, follow the next steps:
> 
> 1. Take a new Cuis 4.1 image.
> 
> 2. From GitHub / garduino clone in your computer the repos
> Cuis-Cryptography
> Cuis-CompatibilityWithOtherSmalltalks
> Cuis-Pharo14CompatibilityLayer
> Cuis-Sport
> Cuis-Swazoo
> 
> 3. In a workspace run the next script:
> 
> | slash repo |
> slash _ FileDirectory slash.
> repo := '/Users/Shared/YOURCODEREPOSITORYPATH/'.
> {
> repo, slash, 'Cuis-Cryptography', slash, 'Cuis-System-Hashing.pck.st' .
> repo, slash, 'Cuis-CompatibilityWithOtherSmalltalks', slash,
> 'Cuis-CompatibilityWithOtherSmalltalks.pck.st' .
> repo, slash, 'Cuis-Pharo14CompatibilityLayer', slash,
> 'Cuis-Network-Protocols.pck.st' .
> repo, slash, 'Cuis-Pharo14CompatibilityLayer', slash,
> 'Cuis-Network-Url.pck.st' .
> repo, slash, 'Cuis-Sport', slash, 'Sport.pck.st' .
> repo, slash, 'Cuis-Swazoo', slash, 'Swazoo.pck.st' .
> }
> do:
> [ :fileName | CodePackageFile installPackageStream:
> (FileStream concreteStream readOnlyFileNamed: fileName)
> ].
> 
> 
> 4. You will notice some warnings in the Transcript regarding some
> Network-* classes, it is because I'm installing here only the minimum
> code that I need for Swazoo and I must still end to polish the delta
> between the Network protocol in Cuis vs Pharo/Squeak
> 
> 5. I did also an early port of TimeStamp, not existing in Cuis, and I
> have still 1 failing test.
> 
> 
> But Swazoo seems to work ok, all the test pass and the tests I did in
> the workspace seems to work, but as I'm not in expert in Swazoo, I
> will be more than happy of receive corrections, suggestion, etc, to
> leave the port in a stable state.

-- 
Janko Mivšek
Aida/Web
Smalltalk Web Application Server
http://www.aidaweb.si




More information about the Cuis mailing list