1 /**
2 Wrapper to use a PacketPeer over a StreamPeer.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.packetpeerstream;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.classdb;
23 import godot.packetpeer;
24 import godot.streampeer;
25 import godot.reference;
26 /**
27 Wrapper to use a PacketPeer over a StreamPeer.
28 
29 PacketStreamPeer provides a wrapper for working using packets over a stream. This allows for using packet based code with StreamPeers. PacketPeerStream implements a custom protocol over the StreamPeer, so the user should not read or write to the wrapped StreamPeer directly.
30 */
31 @GodotBaseClass struct PacketPeerStream
32 {
33 	enum string _GODOT_internal_name = "PacketPeerStream";
34 public:
35 @nogc nothrow:
36 	union { godot_object _godot_object; PacketPeer _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct _classBinding
41 	{
42 		__gshared:
43 		@GodotName("set_stream_peer") GodotMethod!(void, StreamPeer) setStreamPeer;
44 		@GodotName("get_stream_peer") GodotMethod!(StreamPeer) getStreamPeer;
45 		@GodotName("set_input_buffer_max_size") GodotMethod!(void, long) setInputBufferMaxSize;
46 		@GodotName("set_output_buffer_max_size") GodotMethod!(void, long) setOutputBufferMaxSize;
47 		@GodotName("get_input_buffer_max_size") GodotMethod!(long) getInputBufferMaxSize;
48 		@GodotName("get_output_buffer_max_size") GodotMethod!(long) getOutputBufferMaxSize;
49 	}
50 	bool opEquals(in PacketPeerStream other) const { return _godot_object.ptr is other._godot_object.ptr; }
51 	PacketPeerStream opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
52 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
53 	mixin baseCasts;
54 	static PacketPeerStream _new()
55 	{
56 		static godot_class_constructor constructor;
57 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("PacketPeerStream");
58 		if(constructor is null) return typeof(this).init;
59 		return cast(PacketPeerStream)(constructor());
60 	}
61 	@disable new(size_t s);
62 	/**
63 	
64 	*/
65 	void setStreamPeer(StreamPeer peer)
66 	{
67 		checkClassBinding!(typeof(this))();
68 		ptrcall!(void)(_classBinding.setStreamPeer, _godot_object, peer);
69 	}
70 	/**
71 	
72 	*/
73 	Ref!StreamPeer getStreamPeer() const
74 	{
75 		checkClassBinding!(typeof(this))();
76 		return ptrcall!(StreamPeer)(_classBinding.getStreamPeer, _godot_object);
77 	}
78 	/**
79 	
80 	*/
81 	void setInputBufferMaxSize(in long max_size_bytes)
82 	{
83 		checkClassBinding!(typeof(this))();
84 		ptrcall!(void)(_classBinding.setInputBufferMaxSize, _godot_object, max_size_bytes);
85 	}
86 	/**
87 	
88 	*/
89 	void setOutputBufferMaxSize(in long max_size_bytes)
90 	{
91 		checkClassBinding!(typeof(this))();
92 		ptrcall!(void)(_classBinding.setOutputBufferMaxSize, _godot_object, max_size_bytes);
93 	}
94 	/**
95 	
96 	*/
97 	long getInputBufferMaxSize() const
98 	{
99 		checkClassBinding!(typeof(this))();
100 		return ptrcall!(long)(_classBinding.getInputBufferMaxSize, _godot_object);
101 	}
102 	/**
103 	
104 	*/
105 	long getOutputBufferMaxSize() const
106 	{
107 		checkClassBinding!(typeof(this))();
108 		return ptrcall!(long)(_classBinding.getOutputBufferMaxSize, _godot_object);
109 	}
110 	/**
111 	
112 	*/
113 	@property long inputBufferMaxSize()
114 	{
115 		return getInputBufferMaxSize();
116 	}
117 	/// ditto
118 	@property void inputBufferMaxSize(long v)
119 	{
120 		setInputBufferMaxSize(v);
121 	}
122 	/**
123 	
124 	*/
125 	@property long outputBufferMaxSize()
126 	{
127 		return getOutputBufferMaxSize();
128 	}
129 	/// ditto
130 	@property void outputBufferMaxSize(long v)
131 	{
132 		setOutputBufferMaxSize(v);
133 	}
134 	/**
135 	The wrapped $(D StreamPeer) object.
136 	*/
137 	@property StreamPeer streamPeer()
138 	{
139 		return getStreamPeer();
140 	}
141 	/// ditto
142 	@property void streamPeer(StreamPeer v)
143 	{
144 		setStreamPeer(v);
145 	}
146 }