BreepWhatisBreep?
Breepisac++bridgedpeertopeerlibrary.Whatdoesthatmea?Itmeasthatevethoughtheetworkiscostructedasapeertopeeroe,theremaybeodirectcoectiosbetweetwodudes,sayAadB,ifthesecoectiosareimpossible(duetopoorlycofiguredports,forexample).Ithatcase,BreepwillattempttouseaotherpeerCasabridgebetweeAadB.Breepisalsoahigh-levellibrary.Youdo'thavetocareowhepeerscoect,discoect,seddata,adohowtosedyourclasses.Yousimplyregisterlisteersthatgetotifiedwhepeerscomeadgo,whetheysedyoustuff.Youmayeveuseserializatioadsedyourowobjectdirectlythroughtheetwork.Samegoesforyourlisteers:youdo'tsay'Iwattolisteforpilesofbytes',butisteadyousay'Iwattolisteforfacy::MyClass'.
HowdoIuseBreep::etwork?Thebestwaytoowitistoreadthetutorials.Alteratively,youmayreadsomeexamplesadtheoliedoc.Butasalittlepreview,hereisa'HelloWorld!'-typeexample:
Hereishowtocreateaetwork,startlisteigoport1234,adsed"Hello!"toaybudythatcoects:
BREEP_DECLARE_TYPE(std::strig)voidco_listeer(breep::tcp::etwork&etwork,costbreep::tcp::peer&source){etwork.sed_object_to(source,std::strig("Hello!"));}itmai(){breep::tcp::etworketwork(1234);etwork.add_coectio_listeer(&co_listeer);etwork.syc_awake();retur0;}TheBREEP_DECLARE_TYPEivolvedhereisusedtotelltobreep::etworkthatwewillliste/sedsomestd::strigs.Ifyouforgettodoit,youwillgetacompile-timeerror.
Thereishowtodotheopposite:theetworkstartslisteigoport1233,triestocoectatlocalhost:1234,pritsthefirstmessageitsees,thediscoect:
BREEP_DECLARE_TYPE(std::strig)voiddata_listeer(breep::tcp::etdata_wrapper<std::strig>&dw){std::cout<<dw.data<<std::edl;dw.etwork.discoect();}itmai(){breep::tcp::etworketwork(1233);etwork.add_data_listeer<std::strig>(&data_listeer);if(!etwork.coect(boost::asio::ip::address_v4::loopback(),1234)){std::cout<<"Failedtocoect.\";retur1;}etwork.joi();retur0;}Pleasedo'tgetcofused:thereisoUDPithislib(yet).
WhyshouldIuseBreep::etwork?It'sawesome!It'shighlevel:youcadirectlysedadreceiveobjects.Theoverheadforthisislow:ifyousetupwellyourserializatio,youolyhaveafixed64bitsextraoverhead(comparedtosedigrawbytestothep2petwork—icompariso,TCPhas320bitsofoverheadolyforitsheader)It'seasytogeti:justreadtheexamples,you'llsee!WhyshouldINOTuseBreep::etwork?Ithasotbeetestedasmuchasitshouldhavebee.It'sprobablybrokeforBigEdiaarchitecture(Ihaveowaytotestthis,sorry;awarigshouldbedisplayedosucharchitectures.)It'svery,veryslowtocompilewith.RequiremetsResourceRequiremetCompilerC++14compliatoraboveBoostBoost1.55oraboveRoadMapMilestoeFeatureStatus0.1Peertopeeretworkmaagemetcomplete0.1Istatiatedobjectsdeliverycomplete1.0Improvedserializatiocomplete1.0Multipleobjectsdeliveryioegocompletex.xClietserveretworkmaagemetoholdTheprojectiscurretlyotestigstagebeforethereleaseofBreep1.0.0
LiceseThisworkisudertheEuropeaUioPublicLicesev1.1.
YoumaygetacopyofthisliceseiyourlaguagefromtheEuropeaCommissiohere.
Extractofarticle13:
AllliguisticversiosofthisLicece,approvedbytheEuropeaCommissio,haveideticalvalue.Partiescatakeadvatageoftheliguisticversiooftheirchoice.AuthorLucasLazare,aITstudetfrustratedfromotbeigabletoproperlyusejava'sbrokeetworklibrary,adispiredbyKryoNet
评论