-- PDChatServerImpl.mesa
-- Copyright (C) 1984, Xerox Corporation.  All rights reserved.
-- Michael Plass, September 11, 1984 9:14:52 am PDT
	-- 
DIRECTORY PupTypes, PupDefs, PupStream, IO, Rope, Stream, PDUser;
	
PDChatServerImpl: CEDAR PROGRAM
	IMPORTS PupDefs, PupStream, Stream, PDUser
	= BEGIN
		
	NewConnection: PROCEDURE [stream: IO.STREAM, pupAddress: PupDefs.PupAddress] = TRUSTED {
		otherGuy: Rope.ROPE ← PupDefs.GetHostName[pupAddress];
		s: Stream.Handle ← Stream.FromIOStreams[stream, stream];
		PDUser.TalkWithUser[s ! PupStream.StreamClosing => CONTINUE];
		Stream.Delete[s];
		};
		
	pupListener: PupStream.PupListener ← PupStream.CreatePupByteStreamListener[
		local: PupTypes.telnetSoc,
		proc: NewConnection,
		ticks: PupStream.SecondsToTocks[300]
		];
		
	END.