forked from kennytm/ozdss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnection.oz
70 lines (59 loc) · 1.64 KB
/
Connection.oz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
%%%
%%% Author:
%%% Kenny Chan <[email protected]>
%%%
%%% Copyright:
%%% Kenny Chan, 2013
%%%
%%% Last change:
%%% $Date$ by $Author$
%%% $Revision$
%%%
%%% This file is part of Mozart, an implementation of Oz 3:
%%% http://www.mozart-oz.org
%%%
%%% See the file "LICENSE" or
%%% http://www.mozart-oz.org/LICENSE.html
%%% for information on usage and redistribution
%%% of this file, and for a DISCLAIMER OF ALL
%%% WARRANTIES.
%%%
functor
import
DPDefaults
export
OfferOnce
OfferMany
Take
define
{DPDefaults.init}
fun {Take Ticket}
SitePath TicketID
in
{ParseTicket Ticket ?SitePath ?TicketID}
end
%{{{ Implementation ------------------------------------------------------------
AllIPs = {DPDefaults.doGetIp
{Value.condSelect {Property.get 'dp.listenerParams'} ip best}
}
% Generate a unique ticket for others to take.
fun {MakeTicket}
unit
end
% Input: A ticket of the form 'oz-ticket://path#1234'
% Output: A pair (x#y), the first element being the 'path', and the second
% being the
proc {ParseTicket Ticket ?SitePath ?TicketID}
TicketString = {VirtualString.toString Ticket}
in
% Not using compact string until we have compact string literal.
if {List.isPrefix "oz-ticket://" TicketString} then
UriWithoutScheme = {List.drop TicketString {Length "oz-ticket://"}}
Fragment = {String.token UriWithoutScheme &# ?SitePath}
TicketID = {String.toInt Fragment}
else
{Exception.raiseError dp(ticket parse TicketString)}
end
end
%}}}
end