mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-12 15:01:38 +03:00
Finished heartbeat
This commit is contained in:
parent
5acce9cc04
commit
f20944f107
@ -1,4 +1,4 @@
|
||||
!: :: %eyre, http servant
|
||||
:: :: %eyre, http servant
|
||||
!? 164
|
||||
::::
|
||||
|= pit=vase
|
||||
@ -41,7 +41,6 @@
|
||||
== == ::
|
||||
$: %e :: to %eyre
|
||||
$% [%clug p=ship q=hole r=@ud] :: XX terrible
|
||||
[%crud p=@tas q=(list tank)] :: XX rethink
|
||||
[%this p=? q=clip r=httq] ::
|
||||
[%thud ~] ::
|
||||
== == ::
|
||||
@ -173,7 +172,8 @@
|
||||
haw=(map ,@ud swig) :: subscriptions
|
||||
== ::
|
||||
++ swig :: update channel
|
||||
$: cnt=@ud :: updates produced
|
||||
$: hen=duct :: channel duct
|
||||
cnt=@ud :: updates produced
|
||||
toy=@ud :: updates sent
|
||||
wan=(map ,@ud ,@ud) :: upno to reqno
|
||||
red=(map ,@ud (unit (each cage cage))) :: ready for pickup
|
||||
@ -329,14 +329,12 @@
|
||||
::
|
||||
?(%dumb %mean %nice %rush %rust)
|
||||
?> ?=([%hoop @ @ @ @ ~] tea)
|
||||
~& [%dumb-tea tea]
|
||||
=+ ^= ouy
|
||||
%- yolk:(gale (slav %p i.t.tea) i.t.t.tea)
|
||||
(slav %ud i.t.t.t.tea)
|
||||
?~ ouy
|
||||
+>.$
|
||||
~& [%axon-fun `@dr`(sub now tim.bet.siq:beat:u.ouy)]
|
||||
?: (lth ~s20 (sub now tim.bet.siq:beat:u.ouy))
|
||||
?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy))
|
||||
abet:work:amok:u.ouy
|
||||
=+ woy=(yule:u.ouy (slav %ud i.t.t.t.t.tea))
|
||||
=< abet =< work =< abet
|
||||
@ -410,9 +408,6 @@
|
||||
r.kyz
|
||||
?~ ouy
|
||||
+>.$
|
||||
~& [%axon-fun `@dr`(sub now tim.bet.siq:beat:u.ouy)]
|
||||
?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy))
|
||||
abet:work:amok:u.ouy
|
||||
=< abet =< work =< abet
|
||||
(hear:(yule:u.ouy 2) ~ %& %json !>((joba %i-see %s %you)))
|
||||
%crud
|
||||
@ -1054,7 +1049,7 @@
|
||||
var heart = {
|
||||
seqn: 0,
|
||||
trys: 0,
|
||||
dely: 10000,
|
||||
dely: 30000,
|
||||
|
||||
beat: function() {
|
||||
var method, perm, url, $this
|
||||
@ -1592,7 +1587,7 @@
|
||||
(yokg num p.som.pip q.som.pip s.som.pip)
|
||||
::
|
||||
%aph :: heartbeat
|
||||
~& [%wink-aph +.som.pip]
|
||||
:: ~& [%wink-aph +.som.pip]
|
||||
:- [~ pip(pez %way)]
|
||||
(yokh num +.som.pip)
|
||||
::
|
||||
@ -2010,9 +2005,7 @@
|
||||
|= [num=@ud app=term you=ship nap=@ud cnt=@ud jon=json]
|
||||
^+ +>
|
||||
=+ yon=(yolk nap)
|
||||
~& [%yokh-1 cnt]
|
||||
?~ yon (bust 204 num)
|
||||
~& [%yokh-2 cnt]
|
||||
abet:(beat:u.yon cnt num jon)
|
||||
::
|
||||
++ yokm :: message
|
||||
@ -2051,14 +2044,17 @@
|
||||
::
|
||||
++ amok :: demolish
|
||||
^+ ..yo
|
||||
~& %amok-time
|
||||
=+ wuh=(~(tap by haw.siq) ~)
|
||||
|- ^+ ..yo
|
||||
?~ wuh
|
||||
%= ..yo
|
||||
sok (~(del by sok) nap)
|
||||
==
|
||||
$(wuh t.wuh, ..amok (pass p.i.wuh `note`[%g %nuke [our app] you]))
|
||||
%= $
|
||||
wuh t.wuh
|
||||
..amok
|
||||
(pass(hen hen.q.i.wuh) p.i.wuh `note`[%g %nuke [our app] you])
|
||||
==
|
||||
::
|
||||
++ beat
|
||||
|= [cnt=@ud num=@ud jon=json]
|
||||
@ -2070,7 +2066,6 @@
|
||||
%+ pass(bet.siq [+(num.bet.siq) now])
|
||||
2
|
||||
`note`[%e %clug our ses nap]
|
||||
~& [%beat cnt num jon]
|
||||
(hire:(yule 2) cnt num)
|
||||
::
|
||||
++ hoop :: request path
|
||||
@ -2112,7 +2107,10 @@
|
||||
::
|
||||
++ yule :: swig state
|
||||
|= suq=@ud
|
||||
~(. yu suq =+(wig=(~(get by haw.siq) suq) ?~(wig *swig u.wig)))
|
||||
%~ . yu
|
||||
:- suq
|
||||
=+ wig=(~(get by haw.siq) suq)
|
||||
?~ wig [-(hen +)]:[*swig hen] u.wig
|
||||
::
|
||||
++ yu :: swig state
|
||||
|_ [suq=@ud wig=swig]
|
||||
@ -2162,7 +2160,6 @@
|
||||
==
|
||||
sip sip
|
||||
som ^- seam
|
||||
~& [%busk-realz suq]
|
||||
:+ %sil
|
||||
?:(-.u.huq 200 203)
|
||||
=+ bek=`beak`[our %main [%da now]]
|
||||
@ -2187,11 +2184,11 @@
|
||||
=< abet
|
||||
=+ cnt=cnt.wig
|
||||
=+ dul=(~(get by wan.wig) cnt)
|
||||
~& :~ %yu-hear
|
||||
[%instance nap]
|
||||
[%produced cnt]
|
||||
?~(dul %unrequested [%requester u.dul])
|
||||
==
|
||||
:: ~& :~ %yu-hear
|
||||
:: [%instance nap]
|
||||
:: [%produced cnt]
|
||||
:: ?~(dul %unrequested [%requester u.dul])
|
||||
:: ==
|
||||
=: cnt.wig +(cnt.wig)
|
||||
wan.wig ?~(dul wan.wig (~(del by wan.wig) cnt.wig))
|
||||
red.wig (~(put by red.wig) cnt.wig huq)
|
||||
|
@ -74,7 +74,7 @@
|
||||
== ::
|
||||
++ scar :: opaque duct system
|
||||
$: p=@ud :: bone sequence
|
||||
q=(map path ,[p=bone q=(unit cuff)]) :: by duct
|
||||
q=(map duct ,[p=bone q=(unit cuff)]) :: by duct
|
||||
r=(map bone duct) :: by bone
|
||||
== ::
|
||||
++ roon :: foreign response
|
||||
@ -761,7 +761,6 @@
|
||||
deal:(drum u.gad)
|
||||
::
|
||||
%pull
|
||||
~& [%ach-pulled ost]
|
||||
=^ gud +>.$ (mack q.hin)
|
||||
?^ gud +>.$
|
||||
=+ pax=+:(fall (~(get by sup.sat) ost) *[ship path])
|
||||
@ -918,7 +917,6 @@
|
||||
(give(qic.sat ~) %crud p.kon q.kon)
|
||||
::
|
||||
%nuke
|
||||
~& %nukate
|
||||
?. (warm %pull)
|
||||
+>.$(qic.sat ~)
|
||||
?> ?=(^ huv.sat)
|
||||
|
@ -1,234 +0,0 @@
|
||||
!:
|
||||
=> |%
|
||||
++ perm
|
||||
$% [%all ~]
|
||||
[%list p=(list ,@p) q=?]
|
||||
==
|
||||
++ axle
|
||||
$% [%0 p=(map key stat)]
|
||||
==
|
||||
++ comm
|
||||
$% [%change chan=(list key) newchan=key]
|
||||
[%update chan=(list key) sta=stat]
|
||||
==
|
||||
++ gilt
|
||||
$% [%json p=json]
|
||||
[%hymn p=manx]
|
||||
==
|
||||
++ gift
|
||||
$% [%lean ~]
|
||||
[%mean p=(unit ,[p=term q=(list tank)])]
|
||||
[%nice ~]
|
||||
[%rust gilt]
|
||||
[%verb ~]
|
||||
==
|
||||
++ hasp ,[p=ship q=term]
|
||||
++ key ,@tas
|
||||
++ move ,[p=bone q=mess]
|
||||
++ mess
|
||||
$% [%give p=gift]
|
||||
[%pass p=path q=note]
|
||||
==
|
||||
++ note
|
||||
$? $: %a
|
||||
$% [%want p=sock q=path r=*]
|
||||
== ==
|
||||
$: %e
|
||||
$% [%wart p=sock q=@tas r=path s=*]
|
||||
== ==
|
||||
$: %g
|
||||
$% [%mess p=hasp q=ship r=cage]
|
||||
== == ==
|
||||
++ sign
|
||||
$% $: %a
|
||||
$% [%send p=lane q=@]
|
||||
[%went p=ship q=cape]
|
||||
== ==
|
||||
$: %g
|
||||
$% [%rasp (unit (pair logo noun))]
|
||||
== == ==
|
||||
++ stat ,[p=perm q=value]
|
||||
++ value
|
||||
$% [%list p=(list value)]
|
||||
[%text p=@t]
|
||||
[%map p=(map key stat)]
|
||||
==
|
||||
--
|
||||
|_ [hid=hide vat=axle]
|
||||
++ incl
|
||||
|= wal=wall
|
||||
%+ turn wal
|
||||
|= tape ;script(type "text/javascript", src +<);
|
||||
::
|
||||
++ page
|
||||
^- manx
|
||||
;html
|
||||
;head
|
||||
;title: Foobug!
|
||||
;style
|
||||
; #cont {border-collapse: collapse; right: 0px}
|
||||
; #news, .status {
|
||||
; left: 0px;
|
||||
; right: 0px;
|
||||
; background: blue;
|
||||
; color: white;
|
||||
; min-width: 100px;
|
||||
; min-height: 18px;
|
||||
; }
|
||||
; #news {
|
||||
; display: inline-block;
|
||||
; }
|
||||
==
|
||||
;* %- incl :~
|
||||
"//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"
|
||||
==
|
||||
;script ;- (trip ;;(,@ .^(%cx (welp root /urb/js))))
|
||||
==
|
||||
;script ;- (trip ;;(,@ .^(%cx (welp root /app/js))))
|
||||
==
|
||||
==
|
||||
;body
|
||||
;p: Hello.
|
||||
;table#cont:tbody;
|
||||
;button#newb: New Channel
|
||||
;div#news(contenteditable "true");
|
||||
;p: Enter your current status
|
||||
;div#status(contenteditable "true");
|
||||
==
|
||||
==
|
||||
::
|
||||
++ peer
|
||||
|= [ost=bone you=ship pax=path]
|
||||
^- [(list move) _+>]
|
||||
?: =(~ pax)
|
||||
[[ost %give %rust %hymn page]~ +>]
|
||||
:_ +>
|
||||
[ost msg]~
|
||||
::
|
||||
++ parse-acl
|
||||
|= acl=@t ^- perm
|
||||
?: =(%everyone acl)
|
||||
[%all ~]
|
||||
[%list (fall (rush acl (more com ;~(pfix sig fed:ag))) ~) &]
|
||||
::
|
||||
++ poke-json
|
||||
|= [ost=bone you=ship jon=json]
|
||||
^- [(list move) _+>]
|
||||
~& [%poke [%state p.vat] ost you jon]
|
||||
=+ ^= sta %- %- hard ,[%o p=(map ,@t jval)] jon
|
||||
=+ ^= chan %- %- hard ,[~ %s p=@t] (~(get by p.sta) %chan)
|
||||
=+ ^= newc %- %- soft ,[~ %s p=@t] (~(get by p.sta) %newc)
|
||||
=+ ^= acl %- %- soft ,[~ %s p=@t] (~(get by p.sta) %acl)
|
||||
=+ ^= val %- %- soft ,[~ p=jval] (~(get by p.sta) %value)
|
||||
=+ ^= pchan
|
||||
^- (list key)
|
||||
(turn `(list tape)`(rash p.chan (more fas (plus ;~(pose low hep)))) crip)
|
||||
?~ newc
|
||||
?~ val !!
|
||||
?~ acl !!
|
||||
%^ poke-stat ost you :+ %update pchan
|
||||
|- ^- stat
|
||||
:- (parse-acl p.u.acl)
|
||||
?+ -.p.u.val !!
|
||||
%a
|
||||
[%list (turn p.p.u.val |=(j=jval q:^$(p.u.val j)))]
|
||||
%o
|
||||
:- %map
|
||||
%+ ~(rep by p.p.u.val) *(map key stat)
|
||||
|= [p=[p=@t q=jval] q=(map key stat)]
|
||||
(~(put by q) p.p ^$(p.u.val q.p))
|
||||
%s
|
||||
[%text p.p.u.val]
|
||||
==
|
||||
(poke-stat ost you [%change pchan p.u.newc])
|
||||
::
|
||||
++ poke-stat
|
||||
|= [ost=bone you=ship com=comm]
|
||||
=. p.vat
|
||||
|- ^- (map key stat)
|
||||
?< ?=(~ chan.com)
|
||||
?. ?=(~ t.chan.com)
|
||||
%+ ~(put by p.vat) i.chan.com
|
||||
=+ ^= cur
|
||||
%- fall :_ [~ p=all// %map q=*(map key stat)]
|
||||
%- (soft ,[~ p=perm %map q=(map key stat)])
|
||||
(~(get by p.vat) i.chan.com)
|
||||
:- p.cur
|
||||
:- %map
|
||||
%= $
|
||||
chan.com t.chan.com
|
||||
p.vat q.cur
|
||||
==
|
||||
?- -.com
|
||||
%update (~(put by p.vat) i.chan.com sta.com)
|
||||
%change
|
||||
%- %~ del by
|
||||
%+ ~(put by p.vat) newchan.com
|
||||
(fall (~(get by p.vat) i.chan.com) *stat)
|
||||
i.chan.com
|
||||
==
|
||||
:_ +>.$
|
||||
:* ^- move
|
||||
:: :* ost %pass /howdy %a %want [our.hid our.hid] /r/pc
|
||||
:: 'hi'
|
||||
:: ==
|
||||
:: `move`[ost %pass /hi %g %mess [~zod %appbug-2] ~zod %hi !>(~)]
|
||||
:^ ost %give %mean ~
|
||||
(send /status msg)
|
||||
==
|
||||
::
|
||||
++ pour
|
||||
|= [way=path sih=sign]
|
||||
^- [(list move) _+>]
|
||||
~& [%status-pour sih]
|
||||
[~ +>]
|
||||
::
|
||||
++ pull
|
||||
|= ost=bone
|
||||
~& [%status-pull ost]
|
||||
[~ +>.$]
|
||||
::
|
||||
++ root
|
||||
/(scot %p our.hid)/main/(scot %da lat.hid)/app/[app.hid]
|
||||
::
|
||||
++ send
|
||||
|= [pax=path msg=mess]
|
||||
%- turn :_ |=(ost=bone [ost msg])
|
||||
=- ~& [%bones -] -
|
||||
^- (list bone)
|
||||
%+ ~(rep by sup.hid) *(list bone)
|
||||
|= [p=[p=bone q=[ship path]] q=(list bone)] ^- (list bone)
|
||||
?. =(pax +.q.p) q
|
||||
[p.p q]
|
||||
::
|
||||
++ msg
|
||||
^- mess
|
||||
:* %give %rust %json %o
|
||||
%- mo
|
||||
%+ turn (~(tap by p.vat))
|
||||
|= [p=key q=stat]
|
||||
:- p
|
||||
|-
|
||||
?- -.q.q
|
||||
%list
|
||||
[%a (turn p.q.q |=(v=value ^$(q.q v)))]
|
||||
%map
|
||||
:- %o
|
||||
%. :+ %acl %s
|
||||
?- -.p.q
|
||||
%all %everyone
|
||||
%list
|
||||
%+ roll p.p.q
|
||||
|= [p=@p q=@t]
|
||||
(cat 3 (cat 3 q ',') (scot %p p))
|
||||
==
|
||||
%~ put by
|
||||
^- (map ,@t jval)
|
||||
%+ ~(rep by p.q.q) *(map ,@t jval)
|
||||
|= [p=[p=key q=stat] q=(map ,@t jval)]
|
||||
(~(put by q) p.p ^$(q q.p))
|
||||
%text
|
||||
[%s p.q.q]
|
||||
==
|
||||
==
|
||||
--
|
@ -1,121 +0,0 @@
|
||||
window.urb = {
|
||||
ship: ship,
|
||||
port: port,
|
||||
auto: auto,
|
||||
oryx: oryx,
|
||||
user: user,
|
||||
appl: appl,
|
||||
seqn: 0,
|
||||
|
||||
seqp: 1,
|
||||
seqs: 3,
|
||||
dely: 0,
|
||||
|
||||
met: function(str) {
|
||||
beg = str[0]
|
||||
end = str[1]
|
||||
if (ship == user)
|
||||
return perm = beg+"o"+end
|
||||
else
|
||||
return perm = beg+"i"+end+"/"+user
|
||||
},
|
||||
|
||||
req: function(method,url,data,json,cb) {
|
||||
var xhr = new XMLHttpRequest()
|
||||
xhr.open(method.toUpperCase(), url)
|
||||
if(json)
|
||||
xhr.setRequestHeader("content-type", "text/json")
|
||||
if(data)
|
||||
xhr.send(JSON.stringify({oryx: oryx, xyro: data}))
|
||||
else
|
||||
xhr.send({oryx: oryx})
|
||||
if(cb) {
|
||||
xhr.onload = function() {
|
||||
cb(null,{
|
||||
"status":this.status,
|
||||
"data":JSON.parse(this.responseText)
|
||||
})
|
||||
}
|
||||
xhr.onerror = function() {
|
||||
cb({
|
||||
"status":this.status,
|
||||
"data":this.responseText
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
subscribe: function(path,cb) {
|
||||
if(!cb)
|
||||
throw new Error("You must supply a callback to urb.subscribe.")
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
method = "put"
|
||||
|
||||
url = [this.met("ts"),this.appl,this.port]
|
||||
if(path) {
|
||||
url.push(this.seqs)
|
||||
url.push(path)
|
||||
}
|
||||
console.log(url)
|
||||
url = "/"+url.join("/")
|
||||
|
||||
|
||||
$this = this
|
||||
this.req(method,url,{},true,function(err,data) {
|
||||
cb.apply(this,arguments)
|
||||
if(!err) { $this.poll($this.seqs++,cb); }
|
||||
})
|
||||
},
|
||||
|
||||
send: function(data,cb) {
|
||||
if(!data) { data = {}; }
|
||||
if(!cb) { cb = function() {}; }
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
method = "put"
|
||||
url = [this.met("tm"),this.appl,this.port,this.seqn]
|
||||
url = "/"+url.join("/")
|
||||
|
||||
this.seqn++
|
||||
|
||||
$this = this
|
||||
this.req(method,url,data,true,function(err,data) {
|
||||
if(err) { $this.seqn--; }
|
||||
cb.apply(this,arguments)
|
||||
})
|
||||
},
|
||||
|
||||
poll: function(stream,cb) {
|
||||
if(!stream)
|
||||
throw new Error("You must supply a stream to urb.poll.")
|
||||
if(!cb)
|
||||
throw new Error("You must supply a callback to urb.poll.")
|
||||
|
||||
var method, perm, url, $this
|
||||
|
||||
method = "get"
|
||||
if(!stream) { return false; }
|
||||
url = [this.met("ge"),this.appl,this.port,stream,this.seqp]
|
||||
url = "/"+url.join("/")
|
||||
console.log(url)
|
||||
|
||||
$this = this
|
||||
this.req(method,url,null,false,function(err,data) {
|
||||
if(cb.apply(this,arguments) === false) { return; }
|
||||
|
||||
if(err)
|
||||
$this.dely += 1000
|
||||
else {
|
||||
$this.dely = 0
|
||||
$this.seqp++
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
$this.poll(stream,cb)
|
||||
},$this.dely)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user